package jUnitDemo;
import static org.junit.Assert.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
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.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.Select;
public class WebelementsTest {
static WebDriver driver;
static String baseURL;
String k;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
ChromeOptions options = new ChromeOptions();
DesiredCapabilities caps = new DesiredCapabilities();
options.addArguments("--disable-popup-blocking");
caps.setCapability(ChromeOptions.CAPABILITY, options);
driver = new ChromeDriver();
baseURL="https://letskodeit.teachable.com/p/practice/";
//baseURL="https://google.com";
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@Test
public void test() throws InterruptedException {
driver.get(baseURL);
Thread.sleep(5000);
WebElement radio = driver.findElement(By.id("bmwradio"));
radio.click();
boolean t=radio.isSelected();
System.out.println(t);
WebElement lst= driver.findElement(By.id("carselect"));
Select sel=new Select(lst);
sel.selectByIndex(1);
//printing the selected options
List<WebElement> seloptions= sel.getAllSelectedOptions();
for (WebElement opt:seloptions) {
}
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
//driver.quit();
}
}