在网站[https://javapapers.com/core-java/java-qr-code/]中,如果我在浏览器中搜索xpath以下的元素
//div[@id='tutorial-body']/p/img
我得到了两次匹配,但是如果我在硒代码中使用相同的东西
WebDriver driver = new FirefoxDriver();
driver.get("https://javapapers.com/core-java/java-qr-code/");
Thread.sleep(2000);
WebElement qr_url = driver.findElement(By.xpath("//div[@id='tutorial-body']/p/img/"))
String l =qr_url.getCssValue("src");
我遇到以下错误:
Exception in thread "main" org.openqa.selenium.InvalidSelectorException: Given xpath expression "//div[@id='tutorial-body']/p/img/" is invalid: SyntaxError: The expression is not a legal expression.
For documentation on this error, please visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html
那么我的Xpath有什么问题?