use*_*083 10 java selenium xpath webdriver selenium-webdriver
想要使用webdriver获取页面元描述的内容.
让我们说,从DOM下面想要检索文本
Test.com provides a complete software solution for creating online tests and managing enterprise and specialist certification programs, in up to 22 languages
<script src="content/js/jquery.min.js">
<meta content="Test.com provides a complete software solution for creating online tests and managing enterprise and specialist certification programs, in up to 22 languages." name="description">
<meta content="Test.com" name="keywords">
Run Code Online (Sandbox Code Playgroud)
我试过了
System.out.println(driver.findElement(By.xpath("//meta[@name='description']")).getText());
Run Code Online (Sandbox Code Playgroud)
但上面的代码对我不起作用.
har*_*r07 14
您正在尝试获取属性值,因此不要getText()使用getAttribute():
driver.findElement(By.xpath("//meta[@name='description']"))
.getAttribute("content")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6136 次 |
| 最近记录: |