Commit b35682a4 authored by Qazi Zain's avatar Qazi Zain

Third Commit Added StaticDropDown in Web Element Automation

parent 60b551b5
package Techniques_to_automate_web_Element;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class WebElementAutomation {
public static void main(String[] args) {
WebDriver obj = new FirefoxDriver();
// for maximizing the window.
obj.manage().window().maximize();
obj.get("https://rahulshettyacademy.com/dropdownsPractise/");
//------------------------------------> Static DropDown <--------------------------------------------------
WebElement object = obj.findElement(By.cssSelector("select#ctl00_mainContent_DropDownListCurrency"));
Select StaticDropDown = new Select(object);
StaticDropDown.selectByIndex(2);
System.out.println(StaticDropDown.getFirstSelectedOption().getText());
StaticDropDown.selectByValue("INR");
System.out.println(StaticDropDown.getFirstSelectedOption().getText());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment