OperaDriver 0.9 released
OperaDriver 0.9 was released two days ago. It contains quite a few changes and bug fixes, in particular some important API changes I wish to highlight. I'm also happy to introduce OperaProfile and OperaPreferences, two classes for managing an Opera profile and preferences (in both the profile and inside the browser) respectively.
API changes
Essentially many superfluous methods on the OperaDriver and OperaWebElement implementations have been removed to improve the consistency with the official WebDriver interface. Don't panic, though: No functionality has been removed. Instead of using the removed/deprecated method calls there are smarter and better ways:
OperaDriverSettingsremoved- It had been deprecated for a long time already and it was time to remove this ancient relic we used in the past to make the operawatir Ruby gem work. It has now been replaced by
DesiredCapabilities. OperaWebElement.hover(),.mouseOver(),.mouseDown(),.mouseUp(),.rightClick(),dragAndDropBy(),dragAndDropOn()removed- We initially implemented these because Selenium did not have any adequate way of inputting advanced user interactions at the time. Later Selenium introduced the Advanced User Interactions API which we now recommend people to use as a replacement.
middleClick()has been left as-is for the time being, because the new API still lacks this. OperaWebElement.getValue(),.isVisible()removed- Both had been deprecated for quite a while.
getValue()has been replaced bygetAttribute("value"), andisVisible()byisDisplayed(). OperaDriver.getRunner()removed- Used by SpartanRunner, and is now exposed through an extension there.
OperaProfile
OperaProfile is a utility class for managing Opera profiles. It represents a profile (commonly a profile directory) and is typically used by passing in an instance object of this class to the "opera.profile" capability at construction of OperaDriver, like this:
DesiredCapabilities capabilities = DesiredCapabilities.opera();
OperaProfile profile = new OperaProfile();
profile.preferences().set("foo", "bar", "baz");
capabilities.setCapability("opera.profile", profile);
WebDriver driver = new OperaDriver(capabilities);
It can be used, as you just saw, for setting preferences on the profile before Opera is started. This is useful for preferences such as the Ignore Unrequested Popups preference which is enabled by default in other browsers. Enabling this will disable blocking of JavaScript popups, which is required for testing purposes.
If you call OperaProfile's constructor without any arguments, it will produce a fresh random profile that will be populated by Opera once it's started. If you specify a file path or a string directory path, it will manipulate the profile specified.
OperaPreferences
OperaPreferences allows reading and interaction with preferences in the Opera. The old preferences API (OperaDriver.setPref(), .getPref()) has been deprecated in favour of having the same API when interacting with preferences on the profile as well as in the browser.
It can be used like this when setting preferences on a profile:
OperaProfile profile = new OperaProfile(); // will create a random profile
profile.preferences().set("User Prefs", "Ignore Unrequested Popups", false);
And it would work the same way if you wanted to retrieve a preference's value from the browser:
driver.preferences().get("User Prefs", "Ignore Unrequested Popups").getValue();
Interesting bug fixes
- Added stale element checks to
OperaWebElement.getText(),.getLocation(),.getTagName()and.getTagName(). - If a page load times out we now return control of the browser in all situations.
OperaLauncherRunner.isOperaRunning()no longer throws exception if launcher has shut down, but returns false instead.- Fixed issues with
SocketExceptions for double shutdown calls inOperaLauncherRunnerProtocol. - We now throw nice and explanatory error messages if launcher fails to start on Windows, which is likely caused by a missing Visual C++ 2008 runtime.
OperaDriver.close()now quits the browser if it closes the last window.- When using OperaDriver as a Maven dependency it's now able to find the launchers.
For the full list of changes, please see the attached change log.
Get it while it's hot!
The README can be found here: https://github.com/operasoftware/operadriver/blob/v0.9/README.md
OperaDriver 0.9 is available as a part of Selenium 2.17.
If using Maven, OperaDriver 0.9 is available in the group com.opera under the artifact ID operadriver.
You may download the OperaDriver JAR separately here: https://github.com/downloads/operasoftware/operadriver/operadriver-v0.9.zip
The generated API documentation has also been updated and can be found here: http://operasoftware.github.com/operadriver/docs/
Change log
v0.9 (2011-01-16)
[API CHANGES]
* Removed deprecated interface OperaDriverSettings. (andreastt)
* Removed deprecated method OperaWebElement.hover(). (andreastt)
* Removed methods OperaWebElement.mouseOver(), mouseOut(),
mouseDown() and mosueUp(). (andreastt)
* Removed deprecated methods OperaWebElement.getValue() and
isVisible(). (andreastt)
* Removed unknown, unused method OperaWebElement.getElementName().
(andreastt)
* Removed method OperaWebElement.rightClick(). (andreastt)
* Removed deprecated methods OperaWebElement.dragAndDropBy() and
dragAndDropOn(). (andreastt)
* Removed deprecated method OperaDriver.getRunner(). (andreastt)
* OperaDriver's constructor now also takes OperaProfile as an
argument. (andreastt)
* OperaRunnerSettings.setProfile() now accepts an OperaProfile
object as argument. (andreastt)
* The capabilities for Opera now accepts an OperaProfile object for
"opera.profile". (andreastt)
* The capabilities for Opera now accepts a Level object for
"opera.logging.level". (andreastt)
* OperaIntervals.ENABLE_DEBUGGER has been moved to
OperaFlags.ENABLE_DEBUGGER. (andreastt)
* Upgraded Selenium dependency to 2.17. (andreastt)
* Removed interface Utils. (andreastt)
* OperaUtils.getProduct() now returns OperaProduct instead of
String. (andreastt)
* Removed OperaDriver.isJavascriptEnabled(). (andreastt)
* Removed methods OperaDriver.key(), keyDown(), keyUp(),
releaseKeys() and type(). (andreastt)
* Added OperaDriver.manage().logs() to support Selenium 2.16.1.
(ajaykv)
[NEW FEATURES]
* New interface OperaProfile for interacting with the profile for
Opera. You can for example modify or set new preferences on
profile before Opera is started:
OperaProfile profile = new OperaProfile(); // fresh profile
profile.preferences().set("User Prefs",
"Ignore Unrequested Popups", false);
WebDriver driver = new OperaDriver(profile);
You can also interact with existing profiles by passing in the
directory to OperaProfile's constructor.
(andreastt)
* New interface OperaPreferences for managing preferences in
preference files (like operaprefs.ini) and during runtime through
Scope.
Calls to preference may be done like this:
driver.preferences().set("User Prefs",
"Ignore Unrequested Popups", false);
OperaScopePreferences replaces OperaDriver.getPref() and
OperaDriver.setPref() which are now deprecated.
(andreastt)
[ENHANCEMENTS]
* Reduced much code duplication. (andreastt)
* Default product for OperaRunnerSettings is now DESKTOP.
(andreastt)
* Upgraded WebDriver atoms. (andreastt)
* Upgraded OperaWebElement.click() to use new atoms for selecting an
OPTION element. (andreastt)
* Check for whether launcher exists immediately. (andreastt)
* Upgraded operalaunchers to 0.5. Fixes issue with OperaDriver
through Maven not being able to find launchers. (andreastt)
[BUG FIXES]
* Asserting if element is stale on OperaWebElement.getText(),
getLocation(), getTagName() and clear(). (andreastt)
* If a page load times out we now return control of the browser _in
all_ situations. (andreastt)
* Reverted check for setLastModified on newly copied launcher as it
seems to be failing on Windows. (andreastt)
* OperaLauncherRunner.isOperaRunning() no longer throws exception if
launcher has shut down, but returns false instead. (andreastt)
* Object IDs are being garbage collected on each new page load, no
need to store and verify URL when checking for stale elements.
(andreastt)
* OperaLauncherBinary is now using Platform.is() (from Selenium) for
platform comparison. Will output nicer warning when failing on
Windows without VS C++ 2008 redistributable package. (andreastt)
* Fixed issue with SocketException for double shutdown call in
OperaLauncherRunnerProtocol, fixes tests for Windows. (andreastt)
* Getting colours with non-RGB values (such as "transparent") now
works. Resolves issue #49. (andreastt)
* OperaDriver.close() should quit browser if it closes the last
window, resolves issue #48. (andreastt)
[TESTS]
* Added many new test run configurations for IntelliJ. (andreastt)
* Fixed NullPointerException in the case something went wrong during
initialization of OperaDriver in OperaDriverTestCase. (andreastt)
* Added tests for OperaStrings. (ajayk)
* Tests for circumstances where StaleElementReferenceException
should be thrown. (andreastt)
* Refactored many tests so that they pass on Windows, where JUnit
test order is not guaranteed. (andreastt)
* Tests for handing back control to user after reaching
PAGE_LOAD_TIMEOUT. (andreastt)
[OTHER]
* Documented many methods. (andreastt)
* Updated Eclipse configuration. (ajayk)
* Updated IntelliJ configuration for version 11. (andreastt)
* Compile target “compile_tests” now requires “jar”. (andreastt)
* Added more examples to the README. (andreastt)
* Removed old interactions implementation in
com.opera.core.systems.interaction since it was never used.
(andreastt)