使用 Selenium WebDriver 并使用 Java。有什么方法可以在 Selenium WebDriver 中选择 div id 而不是 select id 吗?
我正在使用这个 HTML:
<div id="ui-datepicker-div" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" style="position: absolute; top: 410.8px; left: 998.9px; z-index: 1; display: block;">
最佳答案
您可以在 http://docs.seleniumhq.org/docs/ 上找到文档(带有 java 示例) .
特别是,您正在寻找的方法是
WebDriver.findElement(By)
示例代码是
WebDriver driver = new xxxDriver();
driver.get(" ... ");
WebElement element = driver.findElement(By.id("ui-datepicker-div"));
element. ... // do whatever you want with the DIV block
关于java - 如何使用 Selenium WebDriver 选择 div id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21423547/