Selenium WebDriver findElement(By.xpath()) not working for me

后端 未结 8 1578
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-17 21:34

I\'ve been through the xpath tutorials and checked many other posts, hence I\'m not sure what I\'m missing. I\'m simply trying to find the following element by xpath:

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-17 22:19

    your syntax is completely wrong....you need to give findelement to the driver

    i.e your code will be :

    WebDriver driver = new FirefoxDriver();
    WebeElement element ;
    
    element = driver.findElement(By.xpath("//[@test-id='test-username']"); 
    

    // your xpath is: "//[@test-id='test-username']"

    i suggest try this :"//*[@test-id='test-username']"

提交回复
热议问题