TestingDocs.com
Software Testing website
  • JBehave
  • Selenium
  • Testlink
  • Maven
  • Git
  • RAPTOR
  • Questions

SauceLabs : Running an Example Sample Test

Tweet
Pin it

Document Contents

  • Introduction
  • Capabilities
  • Sample Test:
  • Running Tests in SauceLabs

Introduction

In this post, we will see how to run a sample test on SauceLabs. You need to have a SauceLabs account to set up and run the program. The sample program requires the SauceLabs username and access key.

To get the access key:

https://www.testingdocs.com/saucelabs-credentials-to-run-cloud-tests/

 

SauceLabs Website

Capabilities

Let’s write a sample test that searches the Bing home page for a keyword and asserts the title of the results page.

We will run the program on Mozilla Firefox browser version 46 by setting the DesiredCapabilities and on Windows 10 operating system.

DesiredCapabilities caps = DesiredCapabilities.firefox();
    caps.setCapability("platform", "Windows 10");
    caps.setCapability("version", "46.0");

 

 

Sample Test:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;

import java.net.URL;
 
public class SampleBingTest {
 
  public static final String USERNAME = "SAUCE_USERNAME_GOES_HERE";
  public static final String ACCESS_KEY = "SAUCELAB_ACCESS_KEY_GOES_HERE";
  public static final String URL = "https://" + USERNAME + ":" 
+ ACCESS_KEY + "@ondemand.saucelabs.com:443/wd/hub";
 
  public static void main(String[] args) throws Exception {
 
    DesiredCapabilities caps = DesiredCapabilities.firefox();
    caps.setCapability("platform", "Windows 10");
    caps.setCapability("version", "46.0");
 
    WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
 
    driver.get("https://www.bing.com");
        driver.findElement(By.id("sb_form_q")).sendKeys("HelloWorld");
      driver.findElement(By.id("sb_form_go")).click();
      WebDriverWait wait = new WebDriverWait(driver, 60);
      wait.until(ExpectedConditions.titleContains("Hello"));
      Assert.assertEquals("HelloWorld - Bing", driver.getTitle());
          driver.quit();

   }
}

 

Running Tests in SauceLabs

If you are planning to run your tests on SauceLabs, below are some Basics to follow Before Running Your Test

You need to have set up a Sauce Labs account
You should have an existing Test that you want to run on Sauce.
The website you want to test must be accessible over the Internet for Browsers to be able to reach it.
If the website or application you want to test is behind a firewall, you need to set up a secure Sauce Connect Proxy tunnel to connect to it.

 

Selenium WebDriver Tutorials on this website can be found at:

https://www.testingdocs.com/selenium-webdriver-tutorial

For more details on the Selenium, visit the official website at:

https://www.selenium.dev/

Related Posts

Selenium /

Getting Started with Selenium

Selenium /

Selenium 3.0 and Mozilla GeckoDriver

Selenium /

Create a new Project in Selenium IDE

Selenium /

Hub and Nodes Configuration

Selenium /

What is Selenium Grid ?

Tag Cloud

Agile Appium Tutorials C++ Eclipse Tutorials Git Tutorials IntelliJ Tutorials Java Java Tutorial JBehave Jenkins Jira Cloud JUnit Tutorial Maven Object-oriented Flowchart Python Tutorials Raptor Flowcharts Selenium IDE TestLink Tutorials

Random Posts

  • TestLink Bitnami Cloud Image
    Overview In this tutorial, we will see the steps

    Read more

  • Code Coverage Tools
    Overview Let’s look at some of the code coverage

    Read more

  • pCloudy Continuous Testing Cloud
    Overview pCloudy is a continuous testing cloud

    Read more

Latest Tweets

Tweets by @TestingDocs

Back to Top

TestingDocs.com

  • Privacy Policy
  • Cookie Policy
  • JBehave
  • Selenium
  • Testlink
  • Maven
  • Git
  • RAPTOR
  • Questions
www.TestingDocs.com | All Rights Reserved