4

I am using Fitnesse in order to define some selenium tests. We got all of them running under CHROME but under FIREFOX some exceptions are arising. For running the tests I am using the external chrome webdriver. That is, I am using selenium-server 2.7.0 and starting it in the following way:

D:\projects\dev\jdk\1.6\bin\java -jar ./selenium-server-standalone-2.7.0.jar - Dwebdriver.chrome.driver=c:\chromedriver\chromedriver.exe -Dfile.encoding=UTF8

__EXCEPTION__:org.openqa.selenium.InvalidElementStateException: Cannot perform native interaction: Could not load native events component.; duration or timeout: 2.05 seconds
Build info: version: '2.7.0', revision: '13926', time: '2011-09-23 13:24:59'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_16'
Driver info: driver.version: RemoteWebDriver; duration or timeout: 2.06 seconds
Build info: version: '2.7.0', revision: '13926', time: '2011-09-23 15:09:51'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_16'
Driver info: driver.version: RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:397)
at org.openqa.selenium.remote.ExecuteMethod.execute(ExecuteMethod.java:47)
at org.openqa.selenium.remote.RemoteMouse.mouseMove(RemoteMouse.java:89)
at org.openqa.selenium.interactions.MoveMouseAction.perform(MoveMouseAction.java:37)
at org.openqa.selenium.interactions.CompositeAction.perform(CompositeAction.java:32)
at com.bmw.next.selenium2.util.MouseUtil.moveToElement(MouseUtil.java:22)
    ....

That is, an exception InvalidElementStateException has been thrown and I do not understand what is wrong. The code is the same for Firefox and Chrome. Anybody has experienced this behavior?

Any hint would be appreciated.

Thanks in advance.

4
  • Does this happen with every Firefox mouse interaction, or only sometimes?
    – user246
    Oct 4, 2011 at 16:26
  • What version of Firefox are you running? I had a similar issue running an older version of Firefox that was not supported, and you may run into problems with newer versions of Firefox that haven't been tested yet.
    – Sam Woods
    Oct 5, 2011 at 16:42
  • The last one. 7.0.1
    – Luixv
    Oct 6, 2011 at 7:20
  • it might also be helpful if you give us the code it threw the exception for. Jan 22, 2012 at 2:56

2 Answers 2

1

My guess is that your element is not present. the Click() method using the Firefox driver doesn't work like ClickAndWait in the Selenium IDE. You must explicitly do an implicit wait before you click on something. My guess is that you had 2 clicks right in a row, and it's failing on the second click because that element doesn't exist yet, because the first click submitted a form or something.

Call this method before the line of code that's failing. You'll need to find the Java implementation of this C# code, but I think it might solve your issue.

public static IWebElement FindElement(this IWebDriver driver, By by, int timeoutInSeconds)
{
    if (timeoutInSeconds > 0)
    {
        var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));
        return wait.Until(drv => drv.FindElement(by));
    }
    return driver.FindElement(by);
}
1

You can also follow this procedure.
First, copy your web-element in to a variable of type web-element:

webelement elem=driver.findElement(By.id("elementid"));

Now make the action by

elem.click();

When DOM element changes, the id will not be same as the stack, so when a click action given after the element identification it will again check for the same element again.

This procedure can be used for possible exception like staleelementexception or elementnotfound.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.