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

后端 未结 8 1499
佛祖请我去吃肉
佛祖请我去吃肉 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:30

    Just need to add * at the beginning of xpath and closing bracket at last.

    element = findElement(By.xpath("//*[@test-id='test-username']"));
    
    0 讨论(0)
  • 2020-12-17 22:35

    You can use contains too:

    element = findElement(By.xpath("//input[contains (@test-id,"test-username")]");
    
    0 讨论(0)
提交回复
热议问题