TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    Selenium

    Run an Example Test on 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("Hello");
     driver.findElement(By.id("sb_form_go")).click();
     WebDriverWait wait = new WebDriverWait(driver, 60);
     wait.until(ExpectedConditions.titleContains("Hello"));
     Assert.assertEquals("Hello - 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 Tutorials

    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

    Windows 10 Settings

    Selenium /

    Add Microsoft Webdriver on Windows OS

    Download Selenium Components

    Selenium /

    Getting Started with Selenium Webdriver

    LambdaTest Testing Cloud SaaS Platform

    Selenium /

    LambdaTest – Testing Cloud SaaS Platform

    Selenium /

    Selenium 3.0 and Mozilla GeckoDriver

    Opera Driver Download

    Selenium /

    Download Opera ChromiumDriver on Ubuntu

    ‹ Download Opera ChromiumDriver on Ubuntu› Selenium 3.0 and Mozilla GeckoDriver

    Recent Posts

    • ChatGPT Plans Free and PlusChatGPT Subscription Plans
    • Stellar Converter for Database ToolStellar Converter for Database
    • Stellar MySQL Log AnalyzerStellar Log Analyzer for MySQL
    • Stellar Repair for MySQLStellar Repair for MySQL
    • ChatGPT IntroductionChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI FeaturesChatGPT4 Conversational AI Features
    • Trends in Software EngineeringShaping the Future of Development: Exploring Key Trends in Software Engineering
    • Java PerformanceImproving Java Performance with Multithreading
    • QDrant Vector DatabaseOpen-source Vector Databases
    • Difference between PHP and JavaScript?
    • Bing AI Browser Web ContentBing Conversation Styles
    • ChatGPT PreviewChatGPT Introduction
    • Open Source AI Frameworks TensorFlowOpen Source AI Frameworks
    • Artificial Intelligence Tools

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com