Getting the drop down values in TestNG

package package_name;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.testng.annotations.AfterTest;
import org.openqa.selenium.support.ui.Select;

public class Class_name {
WebDriver driver;

@BeforeTest
public void setup() throws InterruptedException{
System.setProperty(“webdriver.chrome.driver”,”driver path/chromedriver.exe”);
driver = new ChromeDriver();
System.out.println(“Performing the action”);
driver.manage().window().maximize();
driver.get(“Site URL”);
driver.findElement(By.id(“login_email”)).sendKeys(“Username/Mail”);
driver.findElement(By.id(“login_password”)).sendKeys(“Password”);
driver.findElement(By.className(“login button”)).click();
Thread.sleep(1000);
Select dropdown = new Select(driver.findElement(By.className(“search_data[section_id]”)));
dropdown.selectByVisibleText(“video”);
Thread.sleep(10000);
}
@Test
public void preview() throws InterruptedException {
driver.findElement(By.id(“login_search”)).click();
Thread.sleep(6000);
}
@AfterTest
public void teardown() throws InterruptedException {
System.out.println(“Closing the driver”);
Thread.sleep(1000);
driver.close();
}
}

One thought on “Getting the drop down values in TestNG

Leave a comment