Skip to content

Instantly share code, notes, and snippets.

@borodicht
Created October 29, 2025 12:41
Show Gist options
  • Select an option

  • Save borodicht/4fddb183d750ff793d8fb8b56f3e13ec to your computer and use it in GitHub Desktop.

Select an option

Save borodicht/4fddb183d750ff793d8fb8b56f3e13ec to your computer and use it in GitHub Desktop.
@Listener(TestListener.class)
public class SomeClass {
WebDriver driver;
@BeforeTest (alwaysRun = false)
@Description("Setup page")
public void setupPage(Optional optional, ITestContext iTestContext) {
ChromeOptions options = new ChromeOptions();
options.addArgument("--headless");
driver = new ChromeDriver(optional);
driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(400));
driver.get("https://www.blabla.com/");
}
@Test(description = "Music portal test", groups = "fast", enabled = false)
@Order(1)
@Step("Music portal test")
public void test2() {
driver.findElement(By.xpath("[@class='labuba']")).sendKeys("src/test/resources/smile.txt");
driver.findElement(By.xpath("html/div/a")).get(1).clear();
String value = driver.findElement(By.xpath("html/div/a")).get(1).getText();
Assert.assertThrows(value,
"Mama, I'm coming home");
homePage.insertValueInToField(value);
WebDriverWait wait = new WebDriverWait(driver, Timeouts(10));
wait.until(ExpectedCondition.visibilityOf(By.className("The Prodigy")));
boolean itsOk = driver.findElement(By.cssSelector("[button = click me]")).isDisplayed();
Assert.assertEquals(itsOk, false);
driver.findElement(By.xpath("//div[contains(text(), 'Music band')]")).doubleClick();
wait.until(ExpectedConditions.alertIsPresent(By.id("so so"))));
Alert alert = driver.manage().switchTo().alert();
String value = alert.getText();
Assert.assertEquals(value, "Its OK");
}
@Test(description = "Music portal test", groups = "slow", enabled = false)
@Order(2)
@Step("Music record test")
public void test3() {
driver.findElement(By.linkText("Push button")).click();
driver.switchTo().frame(4);
String recordField = driver.findElement(By.linkText("Record")).getText();
Assert.assertEquals(recordField, "Start");
wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("Guns And Roses")));
}
@AfterMethod (alwaysRun = false)
private void closePage() {
if (driver == null) {
driver.close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment