Monday, 23 May 2022

How To Handle Static Dropdown in Selenium | Static Dropdown in Selenium Webdriver using Java

                     In this post, we will see How To Handle Static Dropdown in Selenium | Static Dropdown in Selenium Webdriver using Java 


Program Code:

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;


public class staticdropdown {


public static void main(String[] args) throws InterruptedException 

{

System.setProperty("webdriver.chrome.driver", "C:\\selenium\\chromedriver_win32\\chromedriver.exe");

WebDriver driver=new ChromeDriver();

driver.get("https://www.irctc.co.in/nget/train-search");

Thread.sleep(1000);

driver.manage().window().maximize();

Thread.sleep(1000);

driver.findElement(By.xpath("//button[normalize-space()='OK']")).click();

Thread.sleep(1000);

driver.findElement(By.xpath("//input[@class='ng-tns-c58-8 ui-inputtext ui-widget ui-state-default ui-corner-all ui-autocomplete-input ng-star-inserted']")).click();

Thread.sleep(1000);

driver.findElement(By.xpath("//span[contains(text(),'PUNE JN - PUNE')]")).click();

Thread.sleep(1000);

driver.findElement(By.xpath("(//input[@class='ng-tns-c58-9 ui-inputtext ui-widget ui-state-default ui-corner-all ui-autocomplete-input ng-star-inserted'])[1]")).click();

Thread.sleep(1000);

driver.findElement(By.xpath("//span[normalize-space()='NAGPUR - NGP']")).click();

Thread.sleep(1000);

driver.findElement(By.xpath("//div[@class='ng-tns-c66-12 ui-dropdown ui-widget ui-state-default ui-corner-all']")).click();

Thread.sleep(1000);

driver.findElement(By.xpath("//span[normalize-space()='TATKAL']")).click();

Thread.sleep(1000);

driver.findElement(By.xpath("//button[@type='submit']")).click();

}


}


 Watch following video:



No comments:

Post a Comment