Roe*_*hen 6 selenium selenium-webdriver
我正在使用(selenium webdriver-java)为包含打开小颜色选择窗口的按钮的页面构建测试计划.
这是颜色选择窗口右侧面板的代码:
<span class="ui-colorpicker-bar-layer-pointer">
<span class="ui-colorpicker-bar-pointer" style="top: 51.0333px;"></span>
Run Code Online (Sandbox Code Playgroud)
问题是我如何设置新的风格.....,我找到了这个解决方案:
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementById('colorPickIcon').setAttribute('style', '22.3333px')");
Run Code Online (Sandbox Code Playgroud)
它不起作用....任何建议?
您可以使用findElement而不是getElementById,
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement element = driver.findElement(By.id("colorPickIcon"));
js.executeScript("arguments[0].setAttribute('style', 'top:22.3333px')", element);
Run Code Online (Sandbox Code Playgroud)
您可以参考链接如何使用Selenium WebDriver Java的JavaScript
归档时间: |
|
查看次数: |
20298 次 |
最近记录: |