Reputation: 59
HTML For the element is:
<html>
< div class="view view-text" style="text-decoration: none; top: 9px; width: 216px; font-family: Kiro-webfont,Helvetica Neue,Arial; font-size: 20px; font-weight: bold; text-align: center; color: rgb(255, 255, 255);">OK< / div>
<\html>
X-Path from firebug:
/html/body/div[3]/div/div/div[3]/div/div[3]/div/div[4]/div[2]/div/div/div[1]/div
There is no extra frame. Window is being handled in my code. I am using x-path and unable to find the element with the following error message.
16:45:32.443 INFO - Executing: [find element: By.xpath: /html/body/div[3]/div/div/div[3]/div/div[3]/div/div[4]/div[2]/div/div/div[1]/div]) 16:45:38.258 WARN - Exception thrown org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[3]/div/div/div[3]/div/div[3]/div/div[4]/div[2]/div/div/div [1]/div"} (Session info: chrome=54.0.2840.71) (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 5.03 seconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58' System info: host: 'CTV-RLEE', ip: '10.1.58.129', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_111' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426923 (0390b88869384d6eb0d5d097 29679f934aab9eed), userDataDir=C:\Users\sarshad\AppData\Local\Temp\scoped_dir6280_29240}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouch Screen=false, version=54.0.2840.71, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chro me, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID: fbbb0002ff27c39a173c81cca75088cc * Element info: {Using=xpath, value=/html/body/div[3]/div/div/div[3]/div/div[3]/div/div[4]/div[2]/div/div/div[1]/div} at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363) at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:500) at org.openqa.selenium.By$ByXPath.findElement(By.java:361) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:103) at com.sun.proxy.$Proxy1.findElement(Unknown Source) at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:188) at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:48) at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:1) at java.util.concurrent.FutureTask.run(Unknown Source) at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 16:45:38.263 WARN - Exception: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[3]/div/div/div[3]/div/div[3]/div/div[4]/div[2]/div/div/div[1]/div"} (Session info: chrome=54.0.2840.71) (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 5.03 seconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58' System info: host: 'CTV-RLEE', ip: '10.1.58.129', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_111' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426923 (0390b88869384d6eb0d5d097 29679f934aab9eed), userDataDir=C:\Users\sarshad\AppData\Local\Temp\scoped_dir6280_29240}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouch Screen=false, version=54.0.2840.71, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chro me, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID: fbbb0002ff27c39a173c81cca75088cc * Element info: {Using=xpath, value=/html/body/div[3]/div/div/div[3]/div/div[3]/div/div[4]/div[2]/div/div/div[1]/div}
Upvotes: 1
Views: 1580
Reputation: 23805
You should try using WebDriverWait
to wait until this window dialog button visible and enable to click as :-
new WebDriverWait(driver,10).until(ExpectedConditions.ElementToBeClickable(".//div[text()='OK']"))).click();
Upvotes: 1