WebDriver PhantomJS Unable to find element, but works fine with Firefox

扶醉桌前 提交于 2019-12-04 07:47:18

PhantomJS 1.x has a problem with element IDs. The site is broken, because it uses password for two elements on the page which should never happen. Simply replacing the id in the selector with the element type (input) solves it.

driver.findElement(By.cssSelector("#pintr > input")).sendKeys("1234");

Try the methods from this link

From my experience with WebDriver, it's usually timing issues. Call the method in above link at the beginning of your code so you can make sure everything loads before you try to find them. Or you can simply use Thread.Sleep with long enough time before finding elements.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!