I'm writing a selenium script using java.
In my scenario, I have a select button and a OK button. Select button is enabled and OK button is disabled when I first loaded the page.
When I click on select button, a pop-up window appears. Then I select a date from a date picker in the pop-up window. After selecting the date I click confirm button in the pop-up window. After click on confirm button the pop-up window closes and OK button enables.
This is my test scenario. But, when I run this my test fails at the point of clicking the OK button.
I did lots of research and came up with adding a scroll to my code. Again my test fails at another point (Couldn't select date from the date picker. Cannot imagine how this is happening though.)
Here is my code.
// Click Select button
driver.findElement(By.xpath("//tr[@id='0']/td[2]/a")).click();
System.out.println("User Clicked Select button");
// Select Days
driver.findElement(By.xpath("//div[@id='myModal0']/div/div/div[2]/div/div[2]/div/div/input")).click();
driver.findElement(By.xpath("//div[@id='ui-datepicker-div']/table/tbody/tr[5]/td[7]/a")).click();
System.out.println("User Selected the days the service is offered");
// Click Confirm Button
driver.findElement(By.xpath("//div[@id='myModal0']/div/div/div[2]/div/div[6]/button")).click();
System.out.println("User clicked Confirm Button");
// Page Scroll
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("window.scrollBy(0,250)", "");
// Click OK Button
driver.findElement(By.xpath("/html/body/div[1]/div[4]/div/div[2]/table/tbody/tr[1]/td[6]/button")).click();
System.out.println("User Clicked OK Button");
Here is the error message I've got.
Exception in thread "main" org.openqa.selenium.WebDriverException: Element is not clickable at point (1460.7666015625, 159.03334045410156). Other element would receive the click: Command duration or timeout: 89 milliseconds Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58' System info: host: 'ET_LAHIRU', ip: '192.168.1.4', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_25' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=45.0.1, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID: fea6e350-638c-4cb6-8136-79010aec01a4 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.RemoteWebElement.execute(RemoteWebElement.java:327) at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:85) at selrcdemo.Activities.activities(Activities.java:73) at selrcdemo.ayubomain.main(ayubomain.java:69)
Can someone tell me a solution for this?
Thanks in advance. :)