我的网页上有一个包含9行和6列的表格.我想搜索文本"MakeGoodDisabled-Programwise_09_44_38_461(n)"并获取单元格的xpath.我使用了以下但它失败了,因为它无法在页面中找到文本.你能帮忙吗?我正在使用Selenium Webdriver Junit对此进行编码.
List < WebElement > links = driver.findElements(By.tagName("td"));
Iterator < WebElement > itr = links.iterator();
while (itr.hasNext()) {
String test = itr.next().getText();
if (test.equals("MakeGoodDisabled-Programwise_09_44_38_461(n)")) {
String xpath = driver.findElement(By.name(test)).getAttribute("xpath");
System.out.println(xpath);
}
}
Run Code Online (Sandbox Code Playgroud) 我目前使用以下代码将 div 附加到正文:
$("body").append('<div class="tooltip" id="op" style="position: absolute; z-index: 999; height: 16px; width: 16px; top:70px"><span>Test</span></div>');
Run Code Online (Sandbox Code Playgroud)
我怎么能像上面一样做但不使用jQuery
?