[英]Selenium does not find element by it's xPath
尝试通过其 xPath 从 Facebook 上传一些图像,但运气不佳,还有其他方法吗?
爪哇:
var xPathContato = "//*[@id=\"mount_0_0_lv\"]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div/div/div[4]/div/div/div/div/div/div/div/div/div[3]";
WebElement wb = webDriver.findElement(By.xpath(xPathContato));
String image = wb.getAttribute("src");
URL imageURL = new URL(image );
BufferedImage saveImage = ImageIO.read(imageURL);
ImageIO.write(saveImage, "png", new File("facebook-img"));
错误:
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="mount_0_0_lv"]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div/div/div[4]/div/div/div/div/div/div/div/div/div[3]"}
我认为你在混淆一些东西。 在您上传到 selenium 的页面中,元素并没有真正退出,否则它会毫无问题地显示出来,但该元素基本上只存在于浏览器的开发人员工具栏中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.