想要使用webdriver获取页面meta description的内容。
例如,从以下DOM中想要检索文本:
Test.com提供一种完整的软件解决方案,用于创建在线测试和管理企业和专业认证程序,支持22种语言
<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">
我尝试使用
System.out.println(driver.findElement(By.xpath("//meta[@name='description']")).getText());
但是上面的代码对我没有起作用。