There was a brief discussion on gitter about this yesterday, but I am in a scenario where I know the front end stylesheets play with text, i.e capitalize, uppercase etc, and the test data which is provided is not always going to be in the same case.
Now I believe Selenium only supports XPath 1 so you cannot use the upper/lower case functions there, and the only other approach I know of is the transform approach (all on http://stackoverflow.com/questions/17368189/xpath-lower-case-to-get-a-collection-of-lowercased-values)
So I was just wondering if there was a better way to do this? as ideally I just want a succinct way of saying a=blah
where blah could be BlAH
etc.
is this situation still true? i've also found myself in a spot where i've got elements to select with case-insensitive text values. and i'm struggling to get this functionality going.
This is old so closing. But I think you should always select based on the correct case and update your test data. If you're not then I think your approach to the problem/test is wrong.
there is no "correct case" in some test cases. and one way to approach a test "wrong" would be to create brittle requirements like very precise casing.
const SELECTOR = '.my-selector';
const buttonText = 'blabla';
let elements = $$(`${SELECTOR}`);
const buttons = elements.filter(
li =>
li
.getText()
.toLowerCase()
.indexOf(buttonText.toLowerCase()) > -1
);
const button = buttons[0];
Most helpful comment
there is no "correct case" in some test cases. and one way to approach a test "wrong" would be to create brittle requirements like very precise casing.