Tips and Tricks

Choosing between Marionette and Firefox drivers

The testDestination system property defines the browser that Iridium tests will be run against, and you may notice that you have the option to specify either Firefox or Marionette to run tests against the Firefox web browser. Why are there two options and which one do you pick?

The short answer is use Marionette for recent versions of Firefox.

The long answer involves some history about Firefox and Selenium.

With version 48, Firefox forced the use of signed extensions. Until this point, Selenium used an unsigned XPI to communicate with Firefox, but with version 48 this extension stopped working.

Meanwhile Firefox started work on the Marionette driver, and released a WebDriver that uses Marionette. All newer versions of Firefox were forced to make use of the Marionette driver with Selenium.

Selenium then had two classes that represented each of these drivers: one for Firefox and one for Marionette. From Selenium's point of view Firefox and Marionette were essentially two different browsers.

These days Selenium has removed the Marionette driver and now just has the one Firefox driver, but for the sake of compatibility Iridium still allows users to select between Marionette and Firefox as test destinations.

The following test script can be used to find bad links in a web page. This test specifically tests this very page, which has a dead link down below.

You can run this script by right clicking and saving this web start file.

Feature: Open an application

  # Open up the web page
  Scenario: Launch App
    And I set the default wait time between steps to "2"
    And I open the url "https://autogeneral.gitbooks.io/iridiumapplicationtesting-gettingstartedguide/content/tips_and_tricks.html"
    And I maximise the window
    # This step find all the <a> elements and opens all their href urls
    And I open all links in new tabs and then close the tabs

  Scenario: Verify Response Codes
    # This step reports on any http requests that resulted in HTTP errors.
    # Typically, when used in conjunction with the
    # "I open all links in new tabs and then close the tabs" step, these
    # errors means your site has dead links.
    And I verify that there were no HTTP errors

If you run this test against this page, this link will be flagged as invalid.

Running tests in IE 11

You may see the following error when attempting to run tests in IE 11:

 And I open the page "https://mcasperson.github.io/iridium/examples/test.html" # OpenStepDefinitions.openPage(String,String)
      org.openqa.selenium.NoSuchWindowException: Unable to get browser (WARNING: The server did not provide any stacktrace information)
      Command duration or timeout: 14 milliseconds
      Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
      System info: host: 'Alienware-PC', ip: '169.254.185.10', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0'
      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, proxy={httpProxy=localhost:49697, proxyType=manual}, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:32151/, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss}]
      Session ID: 25bc2a7e-f2f4-4694-bf75-84e3c90bdf79
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:408)

This can be resolved by adding the site you are testing to the list of trusted sites.

If you see errors like Unable to get browser follow the advice in this issue:

According to Jim Evans:

"I've had a little more time to look at this now. I've tested it against the Windows
8.1 preview build available for download from Microsoft.

The good news is that it looks like the IE driver *mostly* works with IE11, provided
that (a) all security zones are set to the same Protected Mode setting and (b) Enhanced
Protected Mode is turned off. Note that the standard registry checks that the IE driver
uses to test for Protected Mode settings in IE7-10 are broken for IE11, and we've never
made any attempt to check for Enhanced Protected Mode, so there's no warning (yet)
if you don't have these settings properly set.

The bad news is that cookie manipulation is broken. Badly. If you attempt to set or
retrieve cookies, there's a chance that you'll end up with the "Unable to get browser"
error encountered before. At the moment, there is no workaround for that. Matt, looking
at the log you posted earlier, it looks like you were doing some cookie manipulation
before you got into the bad state."

Browsers fail to open web pages after running test in IE

The IE WebDriver will set the browser proxy settings, and a crash or termmination of Iridium can leave this proxy information in place. The result is that no browser will be able to open a web page, even though web sites can be resolved and pinged from a command line.

To fix this open up Internet Options, click the Connections tab, click LAN settings, and remove any proxy information.

Clearing the Java Cache

To force Java Web Start to download the latest version of Iridium, you need to clear the Java cache. Open the Java control panel, click Settings -> Delete Files -> All.

Finding XPaths and CSS Selectors

The Chrome developer tools give you an easy way to find the XPath and CSS selectors for an element. Right click on the element, select Copy, and then select Copy XPath.

Besides the Chrome developer tools, there are some Firefox add-ons extensions also which could help you to locate web elements. For example, WebDriver Element Locator is one of them. To use this extension, simply right click on the web element you wish to locate, select an appropriate locator string and it'll be copied to your clipboard.

HTTPS sites not loading with BrowserMob

With BrowserMob enabled, you may find that HTTPS sites don't load when Iridium is run with OpenJDK. Installing the Oracle JDK has been shown to fix this issue.

Zooming in or out of a page

The following JavaScript will enable the browser to zoom in (or out) of the page.

Where '90%' is equal to the desired zoom level.

results matching ""

    No results matching ""