使用Selenium IDE,我们可以突出显示element (以黄色突出显示)。我的意思是,在命令文本字段中,我们输入像- verifyElementPresent这样的命令,在目标字段中,我们输入类似- id=nav-unanswered的内容&当我们点击'Find‘按钮时,网页上的元素被高亮显示。在带有Ruby的Selenium-webdriver中,有没有办法让我们在脚本运行时高亮显示每一个开始执行的元素?
发布于 2012-11-26 15:47:08
有一个java脚本代码,您可以在程序中调用它来突出显示一个元素。但它只能与Selenium-RC或WebDriverBackedSelenium一起使用。
http://code.google.com/p/selenium/source/browse/trunk/java/client/src/org/openqa/selenium/internal/seleniumemulation/htmlutils.js
发布于 2014-06-18 20:16:31
您可以在selenium+java中这样做
public void highlightElement(WebElement element) {
for (int i = 0; i < 2; i++) {
JavascriptExecutor js = (JavascriptExecutor) this.getDriver();
js.executeScript(
"arguments[0].setAttribute('style', arguments[1]);",
element, "color: yellow; border: 3px solid yellow;");
js.executeScript(
"arguments[0].setAttribute('style', arguments[1]);",
element, "");
}
}https://stackoverflow.com/questions/13558291
复制相似问题