HTML:
<html>
<head>
<body onload="document.getElementById('a').style.display='block';">
<div id="a" align="center" onclick="document.location.reload();" style="display: block; cursor: pointer;">
<img width="91" height="24" alt="" src="/CFFileServlet/_cf_captcha/_captcha_img7840336618954261679.png">
</div>
</body>
</html>
Java:
WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='a']")));
I am experiencing difficulties accessing the image or div. My main goal is to retrieve the image source. The body is being blocked upon creation.
Error:
Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 20 seconds waiting for visibility of element located by By.xpath: //div[@id='a']
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47'
System info: host: 'android-PC', ip: '192.168.1.103', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_79'
Session ID: cecb1517-719e-46b1-bbbf-fd44babd7e5b
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=WINDOWS, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=38.0.5}]
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:80)
......