user6323432 user6323432 - 6 months ago 36
Java Question

Often receiving NoSuchElementException while running Selenium test cases

org.openqa.selenium.NoSuchElementException: Unable to find element with name == q (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 395 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 15:28:49'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_01'
Driver info: driver.version: RemoteWebDriver
Session ID: e20f8370-00ed-4bf6-a4fa-a0c09c2b6d8c
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:303)
at org.openqa.selenium.By$ByName.findElement(By.java:291)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:234)

Answer

Yes this is common issue when you use IE.

Open regedit.exe

Open HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones

So Zones will contain 0,1,2,3,4 and on right hand side three columns will be visible as soon as you click on 0 i.e. Name Type Data

Now in Name column look for 2500 Double click it. Put Value data as 3 and Base as Hexadecimal

You did this for 0.

Now repeat the same steps for 1,2,3,4..

Do this for all i.e. 0,1,2,3,4,5 => Change all 2500's value data to 3.

After that run this code.

public static void main(String[] args) throws InterruptedException {

System.setProperty("webdriver.ie.driver", "D:\\Selenium\\CP-SAT\\IEDriver\\IEDriverServer.exe");

WebDriver driver = new InternetExplorerDriver();
driver.get("www.google.com");

It will run on IE. You need a IEDriverServer.exe as i have shown in path, which will run your IE browser.

Reply to me for further query. I ran the above code in eclipse and it ran successfully.

Happy learning :-)

Comments