<html xmlns:plm="http://www.plmxml.org/Schemas/PLMXMLSchema">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>View Health Report</title>
<head>
<body></body>
</html>
我有一个像上面这样的 HTMl,它被插入到 iframe 中。所以我有如下的 Selenium 代码:
//get iframe
WebDriver frame = getFrame()// Brings iframe driver
WebElement html = frame.findElement( By.tagName("html") );// works fine I can see HTMl text from html.getText();
//now try to get title
WebElement title = html.findElement( By.tagName("title"));//title.getText() is always empty.
请让我知道我缺少什么。
最佳答案
尝试 title.getAttribute("innerHTML");
关于java - 在 Selenium 中获取 HTML 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48661324/