This appears as a text box with background colour that is either red or white, according to business rule.
My element locator is:
//body[@id=‘body’]
and my script contains this step:
bgcolor = WebUI.getCSSValue(findTestObject(‘Account/DanAdded-MoveLater/lblImportantCustomer’), ‘background’)
I first set the TD as the locator, then tried the table and finally trying the Body itself.
Also tried CSS locator as ‘background’ and also ‘background-color’.
I can get the text from the element but not the CSS value.
Any help appreciated, thanks Dan
Hi
thanks for the reply - I had assumed that that was the case but using ‘Switch to Frame’ gives me exactly the same result: I can ‘get text’ and click an element, whether I use Switch or not.
The only time I can’tt find the element is if I leave the ‘parent iframe’ out of the table object.
The body of the iframe itself contains the style value ‘background’ - I have tried selecting the ‘body’ as an element, also the ‘table’ and also the ‘td’ (there is only one cell in the table).
I have attached a screenshot of the DOM, as I am wondering whether the ‘== $0’ is important.
You managed to crack it, thanks!
The iframe was not active when I went to get CSS, but I am now able to get CSS value.
I’m a little unsure of behaviour though… since ‘Get Text’ and ‘Click’ worked previously, but not ‘Get CSS value’.
When I changed the parent object value to ‘none’ on my object though, rather than the iframe value, I was suddenly able to get to target the right element. The previous error I got was that ‘Get CSS value’ was unable to find xpath of the actual iframe, rather than the table element. Unsure if this is a bug or expected behaviour - since I would expect ‘Get Text’ to work on the same xpath as ‘Get CSS value’, if same object is used.
No problem. I prefer not to use the ‘parent object’ option, it used to be pretty flaky. Like here:
Another thing to consider is to add a wait condition after switching to the iframe and before interacting with anything in the iframe, just in case the element hasn’t been loaded yet.