我正在尝试通过单击 href 来获取加载的图像的属性。我看到当我单击链接时,它会在主体顶部加载一个包含所有元素的 div。
所以我尝试的是:
js.executeScript("showModal(1,2,'"+nv+"',0);");
WebElement im =(new WebDriverWait(d, 10))
.until(new ExpectedCondition<WebElement>(){
@Override
public WebElement apply(WebDriver d) {
return d.findElement(By.id("imgView"));
}});
System.out.println(im.findElement(By.tagName("img")).getAttribute("src"));
但我检索:
Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 10 seconds waiting for mm.Main$2@741827d1
Build info: version: '2.21.0', revision: '16552', time: '2012-04-11 19:08:38'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8', java.version: '1.6.0_33'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:252)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:221)
at mm.Main.main(Main.java:85)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"imgView"}
Command duration or timeout: 43 milliseconds
该函数showModal
让灯箱发生并加载其中的图像。
我该如何解决?有人能帮我吗?谢谢!!