Coder Social home page Coder Social logo

saucelabs-selenium-demo's Introduction

saucelabs-selenium-demo

Sample project to demonstrate the use of SauceLabs platform to run automated tests in remote browser sessions. This project / test suite uses Selenium + TestNG

Configurations

No additional dependencies specific to SauceLabs need to be added in pom.xml

Driver Setup

Capabilities / BrowserOptions need to be added inorder to run the tests in LambdaTest Browsers. Use SauceLabs Platform Configurator to generate the same for your required platform / browsers versions

  • Sample code for Chrome latest (I am sending the credentials as Parameters and storing them in TestParameters.sl_username, TestParameters.sl_accessKey. U may do the same or hardcode it in the below code.)
         ChromeOptions browserOptions = new ChromeOptions();
        browserOptions.setPlatformName("Windows 11");
        browserOptions.setBrowserVersion("latest");
        Map<String, Object> sauceOptions = new HashMap<>();
        sauceOptions.put("username", TestParameters.sl_username);
        sauceOptions.put("accessKey", TestParameters.sl_accessKey);
        sauceOptions.put("build", "selenium-build-"+System.currentTimeMillis());
        sauceOptions.put("name", "SauceLabsTest");
        browserOptions.setCapability("sauce:options", sauceOptions);
  • Initialize the driver
        URL url = new URL("https://ondemand.us-west-1.saucelabs.com:443/wd/hub");
        driver = new RemoteWebDriver(url, browserOptions);

Passing the Credentials

  • If you would like to pass your SauceLabs credentials during runtime rather than hardcoding it, you can follow the below options:

  • As TestNG parameters

    <parameter name="SLusername" value="YOUR_USERNAME" />
    <parameter name="SLaccessKey" value="YOUR_ACCESSKEY" />
  • As System Properties
    <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version>
        <configuration>
            <suiteXmlFiles>
            <suiteXmlFile>testng.xml</suiteXmlFile>
            </suiteXmlFiles>
            <systemProperties>
                <property>
                    <name>SLusername</name>
                    <value>${SLusername}</value>
                </property>
                <property>
                    <name>SLaccessKey</name>
                    <value>${SLaccessKey}</value>
                </property>
            </systemProperties>
        </configuration>
    </plugin>
  • In this case, you will only be able to trigger the test from CLI
    mvn clean test -DSLusername=YOUR_USERNAME -DSLaccessKey=YOUR_ACCESSKEY

SauceLabs Web UI

You will be able to view the Test Build progress and results from the SauceLabs Dashboard.

  • Log in to your SauceLabs account
  • Navigate to Automated > Test Results.

And you will be able to view the In Progress as well as Completed tests and their details including step wise logs and execution video.

Test Builds

Click on one of the builds and you will be able to see a detailed view of the test execution

Test Details

Detailed Documentation

saucelabs-selenium-demo's People

Contributors

krishnapollu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.