How to get findElementById method?

前端 未结 3 1737
清酒与你
清酒与你 2021-01-29 13:21

I loaded Selenium latest version 3.3.1 to my system through maven dependencies. While trying to code, I couldn\'t get the method findElementById(). Instead, I am ge

相关标签:
3条回答
  • 2021-01-29 13:57

    You should use the method from the class By:

    driver.findElement(By.id("element id")) 
    
    0 讨论(0)
  • 2021-01-29 13:58

    It depends on language you are using for your automation:

    For Java:

    driver().findElement(By.id("locator")).click();
    

    For Python:

    driverInstance.find_element_by_id("Id Locator").click()
    
    0 讨论(0)
  • 2021-01-29 13:59

    add following dependency to maven, do maven clean and maven build

    • Use RemoteWebDriver type while instantiating driver like
      "RemoteWebDriver driver=new FirefoxDriver()" as RemoteWebDriver class has findElementById() method

        < dependency>
        < groupId>org.seleniumhq.selenium</groupId>
        < artifactId>selenium-remote-driver</artifactId>
        < version>3.3.1</version>
       </dependency>
      
    0 讨论(0)
提交回复
热议问题