Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 如何获取findElementById方法?_Selenium_Selenium Webdriver - Fatal编程技术网

Selenium 如何获取findElementById方法?

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

我通过maven依赖项将Selenium最新版本3.3.1加载到我的系统中。在尝试编码时,我无法获取方法
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
    

请阅读。请提供您尝试过的代码和执行结果,包括任何错误消息等。我知道。但在最新版本中,我们使用了durect methid findElementById()。我想得到它
  < dependency>
  < groupId>org.seleniumhq.selenium</groupId>
  < artifactId>selenium-remote-driver</artifactId>
  < version>3.3.1</version>
 </dependency>