optimist_creeper optimist_creeper - 1 year ago 109
Java Question

Finding element using attribute ignoring case

Is there any way to find element using an attribute which must not be case sensitive?

Think that, I want to find element by a title like this:

driver.findElement(By.cssSelector("input[title='This is a Test Title']")).sendKeys("Test");

But change in the title text won't affect my

Answer Source

You can xpath to achieve this. look at below example.

driver.findElement(By.xpath(".//input[translate(@title, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'this is my title']")).sendKeys("Test");

The above xpath will convert all uppercase letters from title to lower case and check if it is equal to given value.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download