operasoftware / operaprestodriver

OperaPrestoDriver is a vendor-supported WebDriver implementation that enables programmatic automation of Presto-based Opera products (i.e. v12 and older).
http://code.google.com/p/selenium/wiki/OperaDriver
Apache License 2.0
149 stars 65 forks source link

NullPointerException when use GetText command #13

Closed jumperchen closed 12 years ago

jumperchen commented 13 years ago

In the org.openqa.selenium.internal.seleniumemulation.GetText#handleSeleneseCommand() method, if the WebDriverException happened, it will use finder.findElement() to receive the element again, but in OperaDriver, it will close the connection when the exception happened.

The exception will cause at com.opera.core.systems.ScopeServices#executeCommand(),

For example,

connection.send(commandBuilder.build());

Note that the connection in this case is null.

Stuk commented 13 years ago

Would you be able to provide an example script that causes this behavior?

jumperchen commented 13 years ago

I used the "Emulating Selenium RC" from the document - http://seleniumhq.org/docs/03_webdriver.html For example, (similar this)

Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl); // Perform actions with selenium selenium.open(url); selenium.getText("some locator we customized!"); // causes an exception.

so it will throw an exception from the customized locator, but it will run with the following code instead.

finder.findElement(driver, locator);

In this case, we customized the finder to find the specific locator for our framework.

You can also refer to this implementation of GetText.java - http://code.google.com/p/selenium/source/browse/trunk/java/client/src/org/openqa/selenium/internal/seleniumemulation/GetText.java?spec=svn11411&r=11411

andreastt commented 12 years ago

Would you be able to provide me with a reproducible test case for this? I've never used Selenium RC styled locators before. Can you share the customized locator you have that fails with OperaDriver with me?

jumperchen commented 12 years ago

is this not good enough?

Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl); // Perform actions with selenium selenium.open(url); selenium.getText("some locator we customized!"); // causes an exception.

andreastt commented 12 years ago

Can you specify what "some locator we customized" is?

jumperchen commented 12 years ago

please refer to these class - https://github.com/zkoss/ztl/blob/master/ztl/src/main/java/org/zkoss/ztl/util/Scripts.java https://github.com/zkoss/ztl/blob/master/ztl/src/main/java/org/openqa/selenium/internal/seleniumemulation/ZKElementFinder.java https://github.com/zkoss/ztl/blob/master/ztl/src/main/java/org/openqa/selenium/internal/seleniumemulation/ZKGetText.java if the getText() method is triggered from our client script, it won't work with Opera driver so that we have to get the element from our finding script before getText.js from the opera driver, you can also check the ZKGetText.java to see how we get around of the issue.

andreastt commented 12 years ago

We've decided not to support Selenium 1 backwards-compatibility.