Selenium 如何获取findElementById方法?
我通过maven依赖项将Selenium最新版本3.3.1加载到我的系统中。在尝试编码时,我无法获取方法Selenium 如何获取findElementById方法?,selenium,selenium-webdriver,Selenium,Selenium Webdriver,我通过maven依赖项将Selenium最新版本3.3.1加载到我的系统中。在尝试编码时,我无法获取方法findElementById()。相反,我得到的只是旧方法findElement()。有人能帮我吗? 注意:在maven中,它只显示最新版本。您应该通过以下方式使用类中的方法: driver.findElement(By.id("element id")) 这取决于您用于自动化的语言: 对于Java: driver().findElement(By.id("locator")).clic
findElementById()
。相反,我得到的只是旧方法findElement()
。有人能帮我吗?
注意:在maven中,它只显示最新版本。您应该通过以下方式使用类中的方法:
driver.findElement(By.id("element id"))
这取决于您用于自动化的语言: 对于Java:
driver().findElement(By.id("locator")).click();
对于Python:
driverInstance.find_element_by_id("Id Locator").click()
向maven添加以下依赖项,执行maven清理和maven构建
- 在实例化驱动程序时使用RemoteWebDriver类型,如
“RemoteWebDriver driver=new FirefoxDriver()”与RemoteWebDriver类相同 findElementById()方法org.seleniumhq.selenium selenium远程驱动程序 3.3.1
< dependency>
< groupId>org.seleniumhq.selenium</groupId>
< artifactId>selenium-remote-driver</artifactId>
< version>3.3.1</version>
</dependency>