//找到路径
WebElement
Xpath=D2.findElementByXPath("//[@id='main']/div/div[2]/div/div/div[1]/div/article/div/span");
//提取值
System.out.println(Xpath.getText());
我希望得到239美元的价值,但得到错误“没有这样的元素”
答案 0 :(得分:0)
啊......好像需要看一下api指南。电话是:
WebElement we = D2.findElement(By.xpath("path"));
// interact with element
we.text(); // or
we.click(); // or whatever else
答案 1 :(得分:0)
请尝试下面适合您的代码
WebElement element = driver.findElements(By.xpath("//span[@class ='price1']"));
System.out.println(element.getText());