在selenium IDE中查找字体权重值 [英] Finding font-weight value in selenium IDE

查看:215
本文介绍了在selenium IDE中查找字体权重值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Selenium IDE,需要确定一个文本项是否有css'font-weight:bold'应用于它(使用'verifyAttribute')



使用以下CSS定位器:

  css = body.home.es ul#languages li:nth-​​child a.selected 

Selenium可以找到该项目。我现在需要深入CSS并确认已经应用了font-weight:bold。我测试的网站的CSS是:

  ul.language li a.selected {
color:#FFFFFF ;
font-weight:bold;

我画了一个空白;可以这样实现,我需要潜入DOM定位器吗?还是Java的解决方案? (对我来说不是那么容易)



感谢您的帮助!

解决方案

因为它看起来像你需要计算风格,我想你需要使用javascript。



你可以通过以下步骤Selenium IDE:

 命令:assertEval 
目标:var x = window.document.querySelector('body.home。 es ul'); window.getComputedStyle(x,null).getPropertyValue('font-weight');
值:700

请注意,值700是粗体的字体粗细。



此解决方案已在Firefox中测试。如果您使用的是IE,则会略有不同 - 请参阅此处。 / p>

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!

解决方案

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.

这篇关于在selenium IDE中查找字体权重值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆