You are on page 1of 2

package atividadeSelenium;

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
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;

class AtividadeNavegador {

static WebDriver driver;


@BeforeAll
static void setUpBeforeClass() throws Exception {
System.setProperty("webdriver.gecko.driver", "D:\\\\A pasta\\\\
geckodriver.exe");
driver = new FirefoxDriver();
}

@AfterAll
static void tearDownAfterClass() throws Exception {
}

@BeforeEach
void setUp() throws Exception {
driver.get("https://www.bbm.usp.br/pt-br/");
}

@AfterEach
void tearDown() throws Exception {
}

@Test
public void testSelectSemClasse() {
WebElement selectPesquisa = driver.findElement(By.cssSelector("div.w-
embed select"));
Select select = new Select(selectPesquisa);
select.selectByVisibleText("EN");
}

@Test
public void testLingua() {
WebElement selectPesquisa = driver.findElement(By.cssSelector("div.w-
embed select.lang-select"));
Select select = new Select(selectPesquisa);
select.selectByVisibleText("EN");
}

@Test
public void testPesquisa() {
WebElement selectPesquisa = driver.findElement(By.cssSelector("div.w-
embed select.select-search"));
Select select = new Select(selectPesquisa);
select.selectByVisibleText("Catálogo (Dedalus)");
}

@Test
public void testPesquisaDuasDivs() {
WebElement selectPesquisa =
driver.findElement(By.cssSelector("div.search-drop > div.w-embed > select"));
Select select = new Select(selectPesquisa);
select.selectByVisibleText("Catálogo (Dedalus)");
}

@Test
public void testPesquisaPorValor() {
WebElement selectPesquisa =
driver.findElement(By.cssSelector("div.search-drop > div.w-embed > select"));
Select select = new Select(selectPesquisa);
select.selectByValue("Site");
}

@Test
public void testPesquisaPorIndex() {
WebElement selectPesquisa =
driver.findElement(By.cssSelector("div.search-drop > div.w-embed > select"));
Select select = new Select(selectPesquisa);
select.selectByIndex(3);
//Esperado: Dicionários
}

@Test
public void testLinguaPorFilhos() {
WebElement selectPesquisa =
driver.findElement(By.cssSelector("select:nth-child(4)"));
Select select = new Select(selectPesquisa);
select.selectByVisibleText("EN");
}

@Test
public void testPesquisaPorAtributo() {
WebElement selectPesquisa =
driver.findElement(By.cssSelector("div[class='w-embed'] select[class='select-
search']"));
Select select = new Select(selectPesquisa);
select.selectByVisibleText("Site");
}
}

You might also like