Tutorials Hut

  • Selenium WebDriver

       Selenium Introduction
       Benefits of Selenium
       Four components of Selenium
       Difference b/w Selenium IDE, RC & WebDriver
       Selenium WebDriver Architecture
       Background when user execute selenium code
       Download and Install Java
       Download and Install Eclipse
       Download Selenium WebDriver
       Selenium WebDriver Locators
       Selenium - Launch Browser
       Selenium WebDriver Waits
       Selenium- Implicit wait
       Selenium- Explicit wait
       Selenium- Fluent wait
       Selenium- Commonly used commands
       Selenium- findElement & findElements
       Selenium- Selenium-Handling check Box
       Selenium- Handling Radio button
       Selenium- Handling drop down
       Selenium- Take Screenshot
       Selenium- Handle Web Alerts
       Selenium- Multiple Windows Handling
       Selenium- Handle iframes
       Selenium- Upload a file
       Selenium- Download a file
       Selenium- Actions Class Utilities
       Selenium- Mouse Actions
       Selenium- Keyboards Events
       Selenium- Handle mouse hover Actions
       Selenium- Drag and Drop
       Selenium- Scroll a WebPage
       Selenium- Context Click / Right Click
       Selenium- Double Click
       Selenium- Desired Capabilities
       Selenium- Assertions
       Selenium- Exceptions and Exception Handling
       Selenium- Difference b/w driver.close() & driver.quit()
       Selenium- difference b/w driver.get() & driver.navigate()
       Selenium- JavascriptExecutor
       Selenium- Read excel file using Fillo API
       Selenium- Database Testing using Selenium
       Selenium- Read & write excel file using Apache POI
       Selenium- Read and Write csv file in Selenium
       Selenium- Dynamic Web Table Handling
       Selenium- Maven Integration with Selenium
       Selenium- Set up Logging using Log4j
       Selenium-Implement Extent Report



  • How to Handle Drop down using Selenium WebDriver with Example

    This article will present you with a complete idea about how to interact with drop down in selenium WebDriver.

    Select Class in Selenium WebDriver

    The ‘Select’ class in Selenium WebDriver is used for selecting and deselecting options in a dropdown.

    The objects of Select Class can be initialized by passing the dropdown webElement as parameter to its constructor.

    WebElement webElementDropDown = driver.findElement(By.id("DropdownID"));  
    Select dropdown = new Select(webElementDropDown);

    A option from drop down can be selected using below methods

    • selectByValue
    • selectByIndex
    • selectByVisibleText

    selectByValue

    select an option from the drop-down based on its index, starting from 0.

    selectByIndex

    select an option from the drop-down based on ‘value’ attribute

    selectByVisibleText

    select an option from the drop-down based on text of the option

    Lets understand all these things using below scenario

    How to Handle Drop down using Selenium WebDriver with Example
    1. Open Chrome Browser
    2. Open URL: https://tutorialshut.com/demo-website-for-selenium-automation-practice/
    3. Select the option “Performance Testing” from the drop-down menu using ‘selectByValue’ method
    4. Select the option “ETL Testing” from the drop-down menu using ‘selectByIndex’ method
    5. Select the option “Functional Testing” from the drop-down menu using ‘selectByVisibleText’ method
    6. Close the browser
    Code Implementation
    package com.test;
    
    import java.util.concurrent.TimeUnit;
    
    import org.openqa.selenium.By;
    
    import org.openqa.selenium.WebDriver;
    
    import org.openqa.selenium.WebElement;
    
    import org.openqa.selenium.chrome.ChromeDriver;
    
    import org.openqa.selenium.support.ui.Select;
    
    import io.github.bonigarcia.wdm.WebDriverManager;
    
    import junit.framework.Assert;
    
    public class HandeDropDownDemo {
    
    public static WebDriver driver;
    
    public static void main(String[] args) throws InterruptedException {
    
    // Create a new instance of the Chrome driver
    
    System.setProperty("webdriver.chrome.driver", "D:\\Drivers\\chromedriver.exe");
    
    driver = new ChromeDriver();
    
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    
    // Launch the URL
    
    driver.get("https://tutorialshut.com/demo-website-for-selenium-automation-practice/");
    
    // Maximize the window
    
    driver.manage().window().maximize();
    
    WebElement webElementDropDown = driver.findElement(By.id("testingDropdown"));
    
    Select dropdown = new Select(webElementDropDown);
    
    // Select the option "Performance Testing" from the drop-down menu using‘selectByValue’ method
    
    dropdown.selectByValue("Performance");
    
    // Select the option "ETL Testing" from the drop-down menu using ‘selectByIndex’ method
    
    dropdown.selectByIndex(3);
    
    // Select the option "Functional Testing" from the drop-down menu using ‘selectByVisibleText’ method
    
    dropdown.selectByVisibleText("Functional Testing");
    
    // close the driver
    
    driver.close();
    
    }
    
    }
    
    



  • Selenium WebDriver Tutorials

       Selenium Introduction
       Benefits of Selenium
       Four components of Selenium
       Difference b/w Selenium IDE, RC & WebDriver
       Selenium WebDriver Architecture
       Background when user execute selenium code
       Download and Install Java
       Download and Install Eclipse
       Download Selenium WebDriver
       Selenium WebDriver Locators
       Selenium - Launch Browser
       Selenium WebDriver Waits
       Selenium- Implicit wait
       Selenium- Explicit wait
       Selenium- Fluent wait
       Selenium- Commonly used commands
       Selenium- findElement & findElements
       Selenium- Selenium-Handling check Box
       Selenium- Handling Radio button
       Selenium- Handling drop down
       Selenium- Take Screenshot
       Selenium- Handle Web Alerts
       Selenium- Multiple Windows Handling
       Selenium- Handle iframes
       Selenium- Upload a file
       Selenium- Download a file
       Selenium- Actions Class Utilities
       Selenium- Mouse Actions
       Selenium- Keyboards Events
       Selenium- Handle mouse hover Actions
       Selenium- Drag and Drop
       Selenium- Scroll a WebPage
       Selenium- Context Click / Right Click
       Selenium- Double Click
       Selenium- Desired Capabilities
       Selenium- Assertions
       Selenium- Exceptions and Exception Handling
       Selenium- Difference b/w driver.close() & driver.quit()
       Selenium- difference b/w driver.get() & driver.navigate()
       Selenium- JavascriptExecutor
       Selenium- Read excel file using Fillo API
       Selenium- Database Testing using Selenium
       Selenium- Read & write excel file using Apache POI
       Selenium- Read and Write csv file in Selenium
       Selenium- Dynamic Web Table Handling
       Selenium- Maven Integration with Selenium
       Selenium- Set up Logging using Log4j
       Selenium-Implement Extent Report

















  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    Scroll to Top