问题
I'm using Selenium IDE and need to identify when an item of text has the css 'font-weight:bold' applied to it (with 'verifyAttribute')
Using the following CSS locator:
css=body.home.es ul#languages li:nth-child(2) a.selected
Selenium can find the item. I now need to dive into the CSS and confirm that font-weight:bold has been applied. The CSS of the site I am testing is:
ul.language li a.selected {
color: #FFFFFF;
font-weight: bold;
I've drawn a blank; can it be achieved this way, do I need to dive into DOM locators? Or is Java the solution? (which for me isn't that easy)
Thanks in advance for your assistance!
回答1:
Since it looks like you need the computed style, I think you you need to use javascript.
You can do this with the following step in Selenium IDE:
Command: assertEval
Target: var x = window.document.querySelector('body.home.es ul'); window.getComputedStyle(x,null).getPropertyValue('font-weight');
Value: 700
Note that the value of 700 is a font-weight of bold.
This solution was tested in Firefox. If you are using IE, it'll be slightly different - see here.
来源:https://stackoverflow.com/questions/10215963/finding-font-weight-value-in-selenium-ide