Forum Discussion

rhu's avatar
rhu
Contributor
3 years ago

How can I generalize e.g. buttons so that they were found also if the name of the button has changed

I have an application that generates some data. Then I want to check this data within a web page. Therefore I navigate to the page and press a button where I should get the data. The problem is that...
  • rhu's avatar
    3 years ago

    I was now able to solve the problem:
    a) not the best solution
    installing/using the intelligent quality ad on for TestComplete:
    This leads to the situation that during testexecution the button first can not be found and then (during execution) the adon tries to find a "similar" button (and this then works - the correct button will be found).
    Same behaviour for other buttons with the "same naming problem".
    But the execution slows down and on the other hand at the end of the test I get some warnings (yellow flags) tthat the bttons could not be fonnd. So this is not an optimal solution.


    b) in this case the better solution:
    I was able to solve the Problem using xpath (unfortunately i am not allowed to paste the full path so i sometimes used ... instead of teh correct naming) like:
    //*[@id="..."]/app-root/div/div/div/app-.../div[2]/div/div/...-button-group/kendo-buttongroup/button[2]

    In this example the "kendo-buttongroup/button[2]" means the button ist the second from the left in the class mentioned before in the x-path.
    As I am not a programmer how did I get this information:
    I used crome as web browser.
    At the web page where the button is displayed I selected the button - pressed right mouse button and the inspect.
    Then the developertoools open and the section of the button is marked.
    Now I click  (right mouse) on the marked section in the devtools and select copy and then either "Copy X Path" or "Copy Full X Path".
    After that I paste that to the name mapping of my button and put it at first place.
    That means, when you click in TestComplete on the teststep where the button is metioned (like GetData1 - as TC did not handle the brackets in the naming) and click right mouse button then you can select "show object in name mappind editor"
    One more comment:
    When openign the developertools and the "button" was marked I sometimes could see that the content was changing.
    So I needed to start the "Copy X Path - action" 2 times to get a working result that solved my proplems.
    Nevertheless maybe there is a better solution using wildcards in X-Path with naming. If somebody knows it, please comment it also here.
    Thanks everybody for your comments and support.