Forum Discussion

MarcusBengtsson's avatar
MarcusBengtsson
Frequent Contributor
4 months ago

Changing xpath trying to wildcard it possible?

Hello!! So ive waited for my license to begin with test complete for months now and finally got it back.

 

Now that I tried to run my test suite it got some errors as expected, the development has been going on still.

But I was wondering if its possible to make this xpath input field a wild card by any chance?

 

It is not (64) earlier it was (68) somehow.. or is it not possible? I want it to click on the "aria-label=name" as shown in image. Or is it dependant on the 64 in this case.

 

2 Replies

  • MarkHays's avatar
    MarkHays
    Occasional Contributor

    As indicated you cannot use a dynamic number in the namemap.   You could use it in code and make a call to FindElement.   However, it appears as if the data you are looking for is in a table that can change.  Additionally any xpath with something such as  //td/th[64] means that it is looking for the 64th instance of that object within the HTML.   In my opinion, this xpath is very susceptible to changes (especially if it is in a table).   I would not map objects in a table, but rather write code that can be used to find the items that you are looking for.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    You can not use wildcard in XPath. 

     

    You should be able to use e.g.

    //*[@aria-label='Name']
    //*[@title='Name']