/
NikolayIvkin
/
tutorials1
Обзор
Документация
Войти
/
NikolayIvkin
/
tutorials1
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
testing-modules/selenium-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java
70 строк
2 KB
Loredana Crusoveanu
split selenium module to move testng code
01 июл 2024, 10:47
01 июл 2024, 10:47
7dedf53
Код
Авторство
О чём код?
package com.baeldung.selenium; import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import com.baeldung.selenium.config.SeleniumConfig; public class SeleniumExample { private SeleniumConfig config; private String url = "http://www.baeldung.com/"; public SeleniumExample() { config = new SeleniumConfig(); config.getDriver() .get(url); } public void closeWindow() { this.config.getDriver() .close(); } public String getTitle() { return this.config.getDriver() .getTitle(); } public void getAboutBaeldungPage() { closeOverlay(); clickAboutLink(); clickAboutUsLink(); } private void closeOverlay() { List<WebElement> webElementList = this.config.getDriver() .findElements(By.tagName("a")); if (webElementList != null) { webElementList.stream() .filter(webElement -> "Close".equalsIgnoreCase(webElement.getAttribute("title"))) .filter(WebElement::isDisplayed) .findAny() .ifPresent(WebElement::click); } } private void clickAboutLink() { Actions actions = new Actions(config.getDriver()); WebElement aboutElement = this.config.getDriver() .findElement(By.id("menu-item-6138")); actions.moveToElement(aboutElement).perform(); } private void clickAboutUsLink() { WebElement element = this.config.getDriver() .findElement(By.partialLinkText("About Baeldung.")); element.click(); } public boolean isAuthorInformationAvailable() { return this.config.getDriver() .getPageSource() .contains("Hey ! I'm Eugen"); } }