1

I have multiple ok buttons in my application in the combinations: OK, ok, oK and Ok. How can i write a single @findby expression to identify all of them with the one webelement. Code example

<button type="button">OK</button>
  • possible duplicate of [case-insensitive matching in xpath?](http://stackoverflow.com/questions/2893551/case-insensitive-matching-in-xpath) – har07 Jun 06 '14 at 06:51

2 Answers2

2

Here is the other solution in pure xpath 1.0 using xpath functions.

 //button[contains('OK,ok,Ok,oK',text())][string-length('OK')=2]

or

//button[contains('OK,ok,Ok,oK',text())][string-length(text())=string-length('OK')]

enter image description here

Edit: Simple approach using translate

//button[translate(text(),'ok','OK')='OK']

enter image description here

supputuri
  • 13,644
  • 2
  • 21
  • 39
1

You can specify matching text with xpath:

//button[text()='OK']

In your case, to match them all:

//button[text()='OK' or text()='oK' or text()='ok' or text()='Ok']
Richard
  • 8,961
  • 3
  • 38
  • 47
  • 3
    or `//button[lower-case(text())=='ok']` – Ajinkya Jun 06 '14 at 06:46
  • 4
    Except that no major browser appears to support XPath 2.0, which means the `lower-case()` will not be recognized. – Richard Jun 06 '14 at 15:00
  • There is a really hacky work around here; http://stackoverflow.com/questions/1625446/problem-with-upper-case-and-lower-case-xpath-functions-in-selenium-ide/1625859#1625859 – Robbie Wareham Jun 07 '14 at 11:28