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 test using RemoteWebDriver with Marionette

    Introduction

    In this post, we will run a sample test using RemoteWebDriver with Marionette. Earlier we have seen how to use Selenium Grid and setup Hub and Nodes Configuration.

    Selenium Grid

    https://www.testingdocs.com/what-is-selenium-grid/

    Grid Configuration

    https://www.testingdocs.com/selenium-grid-hub-and-nodes-configuration/

    Another, pre-requisite for running the program is the grid setup. Hence, I assume hub and nodes are registered properly on the environment. Let’s start writing a sample program to launch Bing website using Selenium Grid with Marionette.

     

    SearchContext

    DesiredCapabilities

    In addition, we will run a sample test case in one of the browser instances that is registered to the remote node. (  Also, we need to use RemoteWebDriver to invoke the browser instance. Furthermore, we need to configure correct DesiredCapabilities to set the browser and platform where the test to be executed.

    To use Firefox with Selenium 3 we need to set system property and capability set to “marionette” true as shown below:

    Setting DesiredCapabilities

    DesiredCapabilities capabilities=DesiredCapabilities.firefox();
    capabilities.setBrowserName("firefox");
    capabilities.setCapability("marionette", true);
    capabilities.setPlatform(Platform.WIN10);

     

    RemoteWebDriver

    Instantiating a remote driver with the desired capabilities as shown below:

    driver = new RemoteWebDriver(new URL(“http://localhost:5555/wd/hub”), capabilities);

    Sample Code Example:

    public class MarionetteExample 
    {
     WebDriver driver;
     
     @BeforeTest
     public void setConfig() throws MalformedURLException
     {
     System.setProperty("webdriver.gecko.driver", "C:\\testingdocs\\geckodriver.exe");
     DesiredCapabilities capabilities=DesiredCapabilities.firefox();
     capabilities.setBrowserName("firefox");
     capabilities.setCapability("marionette", true);
     capabilities.setPlatform(Platform.WIN10); 
     driver = new RemoteWebDriver(new URL("http://localhost:5555/wd/hub"),
     capabilities); 
     }
     
    @Test
    public void sampleTest()
     { 
     driver.get("https://www.bing.com");
     WebElement searchElement = driver.findElement(By.id("sb_form_q"));
     searchElement.sendKeys("hello");
     searchElement.submit();
     WebDriverWait wait = new WebDriverWait(driver, 60);
     wait.until(ExpectedConditions.titleContains("hello"));
     Assert.assertTrue(driver.getTitle().toLowerCase().
    startsWith("hello".toLowerCase()));
     } 
     
    @AfterTest 
    public void closeBrowser()
    {
     if(driver!=null)
     driver.quit(); 
     } 
    }

     

    Run the sample test and we should be seeing a rolling log on the node command prompt with the test running as shown below:

    RemoteNodeLogMarionette

     

    Test Outcome

    The run output of the program as shown in the picture:

    MarionetteExample

     

    Not that we have always use the latest executable that is prepared to run Firefox tests via Marionette. Also, running with the latest exe would make us less prone to errors and exceptions. Furthermore, if we use Firefox 46 or later version we have to switch to use Marionette for our Firefox tests locally or with RemoteWebDriver.

    —

    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

    SauceLabs Website

    Selenium /

    Run an Example Test on SauceLabs

    ‹ WebDriver Actions in Selenium› RemoteWebDriver Tutorial

    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