Finding font-weight value in selenium IDE

走远了吗. 提交于 2019-12-23 04:51:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!