I am in the process of creating script using WebDriver for filter functionality for an application which has field names , operands and search value text boxes.
I have the script for selecting the values from operands drop down like below
List <WebElement> filterdrp = (List<WebElement>) driver.findElements(By.xpath("html/body/div[6]/div/div[2]/div[2]/div/div[2]/div[1]/div/div[2]/div/div[2]"));
WebDriverWait wait = new WebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("/html/body/div[6]/div/div[2]/div[2]/div/div[2]/div[1]/div/div[2]/div/div[2]/div[21]")));
int size = filterdrp.size();
System.out.println(size);
for(int i=1;i<=size;i++)
{
Actions actions = new Actions(driver);
actions.sendKeys(Keys.DOWN).build().perform();//press down arrow key
actions.sendKeys(Keys.ENTER).build().perform();//press enter
}
When I run the script without the above lines, the script is able to identify the search value text box and it runs. When I use these lines I get the error message as
org.openqa.selenium.ElementNotVisibleException: Element is not displayed (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 159 milliseconds
Build info: version: '2.50.1', revision: 'd7fc91b', time: '2016-01-29 19:04:49'
System info: host: 'MXL4080HTD', ip: '172.18.32.188', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, ie.enableFullPageScreenshot=true, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.forceShellWindowsApi=false, pageLoadStrategy=normal, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:43373/, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss}]
Session ID: 84c8353c-3106-44fe-b0a7-6a6782c1945d
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.sendKeys(RemoteWebElement.java:122)
at toStartWith.ReadIntGlobal_data.IntellaGBL_Filter(ReadIntGlobal_data.java:123)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)
The above error is displayed when the control goes to identify the text box for search.
I am getting error at the next line which is below.
driver.findElement(By.xpath("(//input[@type='text'])[5]")).clear();
driver.findElement(By.xpath("(//input[@type='text'])[5]")).sendKeys(values);
driver.findElement(By.className("ApplyFilter")).click();
I tried webdriver wait and other couple of options but it still throws the error.Please help. I have tried using id, name, css to find the element, It works only with xpath. Couldn't generate Relative xpath as it looks like it doesn't have one.