views:

120

answers:

1

I have the following line that works for Firefox

assertTrue(!selenium.isElementPresent("//input[@name=\""+chosen.getField().getName()+"\" and contains(@style, \"color: rgb(255, 0, 0);\")]"));

But Fails in IE.

When i inspect the field in IE, i see the color style represented in hexadecimal. How would you represent the line above to work on IE?

+1  A: 

The main problem with the style attributes and IE is that it interprets them in Uppercase, no matter what the html source has. We've documented this in: http://seleniumhq.org/docs/05%5Fselenium%5Frc.html#ie-and-style-attributes

So, for that locator you should start by using:

assertTrue(!selenium.isElementPresent("//input[@name=\""+chosen.getField().getName()+"\" and contains(@style, \"COLOR: rgb(255, 0, 0);\")]"));

In case the color is not matched, you can create a try - catch structure, where you assert for the input, if it fails, you catch it and assert for the same input using UPPERCASE (this way will work in both IE and the rest of the browsers...

In case in IE the color is not interpreted that way, you can add the IE way in the locator with uppercases inside the catch sentence.

Anyway, this awful problem would be fixed for you if the devs replace that static styling by adding a class to the desired input and then implementing the style using regular css.

Santi