Skip to content

Instantly share code, notes, and snippets.

@rodrigoprestesmachado
Created November 1, 2023 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodrigoprestesmachado/f197484e99ea175a830a4f78b11d8255 to your computer and use it in GitHub Desktop.
Save rodrigoprestesmachado/f197484e99ea175a830a4f78b11d8255 to your computer and use it in GitHub Desktop.
Selenium
package dev.orion.talk.system;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class SsiTest {
static WebDriver driver;
static Map<String, Object> vars;
static JavascriptExecutor js;
@BeforeAll
public static void setUp() {
ChromeOptions options = new ChromeOptions();
//options.addArguments("--headless");
//options.addArguments("--disable-gpu");
driver = new ChromeDriver(options);
js = (JavascriptExecutor) driver;
vars = new HashMap<String, Object>();
}
@AfterAll
public static void tearDown() {
driver.quit();
}
@Test
@Order(1)
void ssi() {
// Wait for 2 seconds to load the page
Duration duration = Duration.ofSeconds(2);
driver.get("https://poa.ifrs.edu.br/");
driver.manage().window().setSize(new Dimension(1280, 1055));
driver.findElement(By.linkText("Cursos")).click();
driver.findElement(By.linkText("Curso Superior de Tecnologia em Sistemas para Internet")).click();
driver.manage().timeouts().implicitlyWait(duration);
assertTrue(driver.findElement(By.cssSelector("ul:nth-child(6) > li:nth-child(1) > span"))
.getText().matches("^[\\s\\S]*Coordenador[\\s\\S]*$"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment