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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

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

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Implementing Infrastructure as Code (IaC) for Data Center Management
  • On SBOMs, BitBucket, and OWASP Dependency Track
  • Scaling CI/CD: Standardizing Pipelines in Large-Scale Organizations
  • Enhancing Security in Kubernetes: A Comparative Analysis of Cosign and Connaisseur

Trending

  • Understanding the Shift: Why Companies Are Migrating From MongoDB to Aerospike Database?
  • The Perfection Trap: Rethinking Parkinson's Law for Modern Engineering Teams
  • Advancing Robot Vision and Control
  • A Guide to Auto-Tagging and Lineage Tracking With OpenMetadata
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. CI Testing With Iridium and PhantomJS

CI Testing With Iridium and PhantomJS

Using PhantomJS is an easy way to add testing to your automated build process, and with Iridium it is trivial to swap between browsers in your various environments.

By 
Matthew Casperson user avatar
Matthew Casperson
·
Jul. 14, 16 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
2.7K Views

Join the DZone community and get the full member experience.

Join For Free

In a previous article, I showed you how to write a simple test in Iridium that navigated the DZone website in Firefox. When the test was run, you could see Firefox start and begin clicking through the site.

Testing in desktop browsers is valuable when you need to simulate the end-user experience, and is an excellent way to ensure that your site works across multiple browsers. But, you’ll also want to be able to run tests in a headless environment like Jenkins or Bamboo on a regular basis to ensure that changes don’t break the expected behaviour of your application.

PhantomJS provides a headless browser that runs in CI environments, and Iridium supports PhantomJS out of the box. To see this in action, right click and download the Web Start file, and then run it. Note that you will want to enable the Web Start console so you can see what is going on. Refer to the Installation chapter of the Iridium Getting Started Guide for more details.

The complete jnlp file is shown below:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="https://s3-ap-southeast-2.amazonaws.com/ag-iridium/">
    <information>
        <title>Iridium Web Application Tester</title>
        <vendor>Auto and General</vendor>
        <homepage href="https://autogeneral.gitbooks.io/iridiumapplicationtesting-gettingstartedguide/content/"/>
        <offline-allowed/>
    </information>
    <resources>
        <!-- Application Resources -->
        <j2se version="1.8+" href="http://java.sun.com/products/autodl/j2se"/>
            <property name="jnlp.packEnabled" value="true"/>
            <property name="javaws.configuration" value=""/>
            <property name="javaws.dataset" value=""/>
            <property name="javaws.appURLOverride" value="https://dzone.com"/>
            <property name="javaws.featureGroupName" value=""/>
            <property name="javaws.testSource" value="https://raw.githubusercontent.com/AutoGeneral/IridiumApplicationTesting/master/examples/17.simplesteps/test.feature"/>
            <property name="javaws.importBaseUrl" value=""/>
            <property name="javaws.testDestination" value="PHANTOMJS"/>
            <property name="javaws.webdriver.chrome.driver" value=""/>
            <property name="javaws.webdriver.opera.driver" value=""/>
            <property name="javaws.phantomjs.binary.path" value=""/>
            <property name="javaws.leaveWindowsOpen" value="false"/>
            <property name="javaws.openReportFile" value="true"/>
            <property name="javaws.saveReportsInHomeDir" value="true"/>
            <property name="javaws.webdriver.ie.driver" value=""/>
            <property name="javaws.enableVideoCapture" value="false"/>
            <property name="javaws.numberOfThreads" value="1"/>
            <property name="javaws.numberURLs" value="1"/>
            <property name="javaws.numberDataSets" value="1"/>
            <property name="javaws.enableScenarioScreenshots" value="true"/>
            <property name="javaws.tagsOverride" value=""/>
            <property name="javaws.phantomJSLoggingLevel" value="NONE"/>
            <property name="javaws.startInternalProxy" value=""/>
            <property name="jnlp.versionEnabled" value="true"/>
            <jar href="webapptesting-signed.jar" main="true" version="0.0.4" />
    </resources>
    <application-desc
        name="Web Application tester"
        main-class="au.com.agic.apptesting.Main"
        width="300"
        height="300">
    </application-desc>
    <update check="background"/>
    <security>
        <all-permissions/>
    </security>
</jnlp>

Once launched, the test will run through from the command line without the need for a desktop browser.

The only change that was required was defining the testDestination system property:

<property name="javaws.testDestination" value="PHANTOMJS"/>

There are three other system properties that you should be aware of when running tests in PhantomJS.

The first is the phantomJSLoggingLevel property, which configures the logging level of the PhantomJS browser. PhantomJS was quite verbose with its default settings, which ended up cluttering the console output, so I usually leave this as NONE unless I need to debug an issue with a test script.

The second is the enableScenarioScreenshots property, which when set to true will automatically grab a screenshot of the webpage at the end of each scenario. Since you can’t see the test interacting with the webpage with a headless browser like PhantomJS, these screenshots are invaluable for debugging tests.

The final property is phantomjs.binary.path, which can be set to the PhantomJS executable downloaded from the PhantomJS website. This is optional, as Iridium includes a version of PhantomJS that is automatically configured for you, but you can override the included version through this system property.

Using PhantomJS is an easy way to add testing to your automated build process, and with Iridium it is trivial to swap between browsers in your various environments.

Related Refcard:

Continuous Integration

Continuous Integration/Deployment

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

Opinions expressed by DZone contributors are their own.

Related

  • Implementing Infrastructure as Code (IaC) for Data Center Management
  • On SBOMs, BitBucket, and OWASP Dependency Track
  • Scaling CI/CD: Standardizing Pipelines in Large-Scale Organizations
  • Enhancing Security in Kubernetes: A Comparative Analysis of Cosign and Connaisseur

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!