DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Culture and Methodologies
  3. Career Development
  4. Free Remote End-to-End Tests With Edge, Browserstack, and Iridium

Free Remote End-to-End Tests With Edge, Browserstack, and Iridium

Learn how to run end-to-end tests on your web applications using three powerful, and free, tools and just a little bit of code.

Matthew Casperson user avatar by
Matthew Casperson
·
May. 16, 17 · Tutorial
Like (1)
Save
Tweet
Share
4.38K Views

Join the DZone community and get the full member experience.

Join For Free

Often one of the trickiest aspects of running end-to-end tests is getting a browser to run within a CI environment. These environments are almost always headless, and while both Chrome and Firefox are bringing headless browsing to the mainstream in coming releases, right now you still have to do some work with utilities like xvfb to run browsers without a display. And if you want to test on Microsoft browsers like Edge or IE, or mobile browsers, your Linux CI server just isn’t going to cut it.

Services like Browserstack provide a solution by allowing you to run your Selenium tests on browsers hosted by them. This gives you access to multiple browsers in multiple operating systems. It has been hard to justify the expense of a service like BrowserStack for individual development, but recently Microsoft and Browserstack teamed up to offer unlimited hours of testing against Edge.

Using Iridium it is dead simple to get started with end-to-end testing in Browserstack.

Before we begin, make sure you have Java 8 installed on your PC.

Then sign up for a Browserstack account. In your account settings, you will find a username and access key that you can use to for the Automate service, which is how we run remote tests.

browserstack.png

To start running remote tests with Iridium you’ll need 3 files. The first is the feature file that defines the actual test. In honor of Microsoft giving us all free testing, I have written a short test for the Contoso University, which is a sample .NET web app supplied by Microsoft and made available online here.

This test clicks a few links and updates a student name.

Feature: End to end test of Contoso University
  Scenario: Create aliases
    Given I set the alias mappings
      | Alexander Carson Edit | /html/body/div[2]/table/tbody/tr[2]/td[4]/a[1] |
      | Last Name | LastName |

  Scenario: Open the app
    Given I open the page "https://contoso.azurewebsites.net"
    Then I wait "30" seconds for the page to contain the text "Contoso University"

  Scenario: Open the main links
    And I click the "About" link
    Then I wait "30" seconds for the page to contain the text "Student Body Statistics"

    And I click the "Students" link
    Then I wait "30" seconds for the page to contain the text "Find by name"

    And I click the "Courses" link
    Then I wait "30" seconds for the page to contain the text "Department"

    And I click the "Instructors" link
    Then I wait "30" seconds for the page to contain the text "Hire Date"

    And I click the "Departments" link
    Then I wait "30" seconds for the page to contain the text "Administrator"

  Scenario: Edit a student
    And I click the "Students" link
    Then I wait "30" seconds for the page to contain the text "Find by name"

    And I click the "Alexander Carson Edit" link
    And I clear the "Last Name" text box
    And I populate the "Last Name" text box with "John"
    And I click the "Save" button

Next, you will need a configuration file that defines the capabilities of the browser that we will be testing against in Browserstack. In our case, we are requesting the Edge browser running in Windows 10. This combination gives us free testing in Browserstack.

<profile>
    <settings>
        <desiredCapabilities enabled="true" group="Edge">
            <capability name="platform" value="WINDOWS"/>
            <capability name="browserName" value="edge"/>
        </desiredCapabilities>
    </settings>
</profile>

Finally, we need a Web Start file to run the test. This file is a launcher that Java can use to download Iridium and run the selected test.

Note the properties called browserStackUsername and browserStackAccessToken. You will need to set these values to those that match your BrowserStack credentials. You'll also want to update the testSource and configuration values to reflect the path of the feature and xml file.

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="https://s3-ap-southeast-2.amazonaws.com/ag-iridium/">
    <information>
      <title>Iridium</title>
      <vendor>Auto and General</vendor>
    </information>
    <resources>
        <j2se version="1.8+" href="http://java.sun.com/products/autodl/j2se"/>
        <property name="jnlp.packEnabled" value="false"/>
        <property name="javaws.testSource" value="/Users/me/Documents/contosouniversity.feature"/>
        <property name="javaws.configuration" value="/Users/me/Documents/contosouniversity.xml"/>
        <property name="javaws.testDestination" value="BrowserStack"/>
        <property name="javaws.browserStackUsername" value="matthewcasperson2"/>
        <property name="javaws.browserStackAccessToken" value="accesskeygoeshere"/>
        <property name="javaws.openReportFile" value="true"/>
        <property name="javaws.saveReportsInHomeDir" value="true"/>
        <jar href="IridiumApplicationTesting.jar" main="true" />
    </resources>
    <application-desc
        name="Web Application tester"
        main-class="au.com.agic.apptesting.Main">
    </application-desc>
    <update check="timeout" policy="always"/>
    <security>
        <all-permissions/>
    </security>
</jnlp>

Assuming you have installed Java 8 correctly, double clicking on the jnlp file will launch Iridium and run the test in BrowserStack against a remote Edge browser. You can see the end result of such a test in this Youtube video.

You can download these test files here.

If you are interested in writing end-to-end tests like the one shown above, check out the Iridium documentation page, and take a look at the courses available on Udemy. Iridium itself is a free and open source project on GitHub.

Testing workplace

Published at DZone with permission of Matthew Casperson, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • 7 Awesome Libraries for Java Unit and Integration Testing
  • An Introduction to Data Mesh
  • Understanding gRPC Concepts, Use Cases, and Best Practices
  • Stream Processing vs. Batch Processing: What to Know

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: