Html 验证样式属性中css属性的Selenium测试
我想编写一个selenium IDE测试,验证下面“style”中底部属性的值。假设: 元素的Xpath是:Html 验证样式属性中css属性的Selenium测试,html,css,selenium,xpath,Html,Css,Selenium,Xpath,我想编写一个selenium IDE测试,验证下面“style”中底部属性的值。假设: 元素的Xpath是:Xpath=/html/body/div/div[3]/div[2]/div/div/div[3]/div/a 我想使用verifyAttribute或类似工具 我正在使用selenium IDE:命令、目标、值 <a href="#" class="ui-slider-handle ui-state-default ui-corner-all" style="bottom: 75%
Xpath=/html/body/div/div[3]/div[2]/div/div/div[3]/div/a
我想使用verifyAttribute或类似工具
我正在使用selenium IDE:命令、目标、值
<a href="#" class="ui-slider-handle ui-state-default ui-corner-all" style="bottom: 75%; background-color: transparent;"></a>
我相信这样做会奏效:
COMMAND | TARGET | VALUE
verifyAttribute | css=input + input@id | id
我建议您不要使用Selenium IDE。查看xpath以获得一个简单的链接,它非常复杂且非常难以阅读。如果您想长期维护测试并获得ROI,请自己编写css/xpath。也可以使用
WebDriver
而不是Selenium 1.0
<代码>Selenium 1.0处于维护模式
WebDriver driver = new FirefoxDriver();
driver.get("http:\\your.site.com");
WebDriverWait wait = new WebDriverWait(driver,60);
By findBy = By.cssSelector("a.ui-corner-all")
WebElement element = wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(findBy));
String bottom_cssValue = element.getCssValue("bottom");
System.out.println(bottom_cssValue);
或者xpath target://*[@id=“myId”]@classAnd为样式进行自定义:target://*[@id=“myId”]@style-VALUE:bottom:75%;背景色:透明;我同意你的看法。然而,我工作场所的ISO和法规阻止我轻松安装/修改环境,因此求助于firefox插件是有意义的。我现在自己也在写XPath。更干净。。。