-2

I need to input field value in application and no unique attribute for that field. Due to that I am using text() function and it worked. This application changes slightly between vendors.

In application, for vendor1, field name is: Physical street address

for other vendor, it is Physical Street Address

Streed and Address are case sensitive between two vendors and due to this my script is failing.

My xPath which is working for second vendor but failing for first vendor:

    //tr[td[contains(text(),'Physical Street Address')]]/td//input[contains(@id, 'part1')]

I checked with translate but it is not working.

ravi ch
  • 31
  • 4
  • Possible duplicate of [case insensitive xpath contains() possible?](https://stackoverflow.com/questions/8474031/case-insensitive-xpath-contains-possible) – JeffC Jan 31 '19 at 18:04

2 Answers2

0

Not sure why translate() didn't work at your end. Perhaps your code trials may have helped us to debug the issue. You can use the following solution:

//tr[td[translate('Physical Street Address','abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')]]/td//input[contains(@id, 'part1')]
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

I'm sure there is a more elegant solution, but I think it should work too

//tr[td[contains(text(),'Physical Street Address') or contains(text(),'Physical street Address')]]/td//input[contains(@id, 'part1')]
  • Sorry, forget to make 'Addres' in the second condition from the lower letter too. – Aleksandr Efimov Jan 31 '19 at 15:05
  • Even after publishing your answer you can modify your answer by clicking on the `edit` link just below your answer which is in-between `share` and `flag` links. Let me know if you still need help to do so and need further assistance. – undetected Selenium Jan 31 '19 at 19:26