我正在为其编写脚本的应用程序(在Ruby中使用selenium-webdrive )是用AJAX构建的。在这方面,我想检查内容是否是灰色的-
我点击了buttonThen,div是加载的,但是我可以看到内容是灰色的&下面是firebug中的div
<div id="bottomHalf" class="disabled" style="background-color: transparent;">为了检查它是否变灰了,我很困惑如何编写代码。基于我的优势,我只能找到元素-
driver.find_element(:id, "bottomHalf")但是,我不知道如何编写检查class=“禁用”的代码,这样我就可以验证内容是否真的变灰了。
发布于 2012-11-27 10:45:30
发布于 2012-11-27 10:44:57
在正确的方向上,mate...After找到一个元素,您可以检索该元素的属性。在Ruby中,使用以下方法。
# get an attribute
class_name = element.attribute("class")以下是C#中查找元素后检索属性值的示例。
driver.Navigate().GoToUrl("http://google.com");
IWebElement Element = driver.FindElement(By.Id("gbqfq"));
String Class_name = Element.GetAttribute("Class");查看此URL以获得更多特定于Ruby的绑定http://code.google.com/p/selenium/wiki/RubyBindings
https://stackoverflow.com/questions/13581058
复制相似问题