Group testing modules (#3014)
* move security content from spring-security-rest-full * swagger update * move query language to new module * rename spring-security-rest-full to spring-rest-full * group persistence modules * group testing modules * try fix conflict
This commit is contained in:
committed by
GitHub
parent
b383d83bf4
commit
776a01429e
+63
@@ -0,0 +1,63 @@
|
||||
package main.java.com.baeldung.selenium;
|
||||
|
||||
import main.java.com.baeldung.selenium.config.SeleniumConfig;
|
||||
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.interactions.Actions;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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() {
|
||||
this.config.getDriver().findElement(By.partialLinkText("About")).click();
|
||||
}
|
||||
|
||||
private void clickAboutUsLink() {
|
||||
Actions builder = new Actions(config.getDriver());
|
||||
WebElement element = this.config.getDriver().findElement(By.partialLinkText("About Baeldung."));
|
||||
builder.moveToElement(element).build().perform();
|
||||
}
|
||||
|
||||
public boolean isAuthorInformationAvailable() {
|
||||
return this.config.getDriver()
|
||||
.findElement(By.cssSelector("article > .row > div"))
|
||||
.isDisplayed();
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package main.java.com.baeldung.selenium.config;
|
||||
|
||||
import org.openqa.selenium.Capabilities;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||
import org.openqa.selenium.remote.DesiredCapabilities;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class SeleniumConfig {
|
||||
|
||||
private WebDriver driver;
|
||||
|
||||
public SeleniumConfig() {
|
||||
Capabilities capabilities = DesiredCapabilities.firefox();
|
||||
driver = new FirefoxDriver(capabilities);
|
||||
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
static {
|
||||
System.setProperty("webdriver.gecko.driver", findFile("geckodriver.mac"));
|
||||
}
|
||||
|
||||
static private String findFile(String filename) {
|
||||
String paths[] = {"", "bin/", "target/classes"}; // if you have chromedriver somewhere else on the path, then put it here.
|
||||
for (String path : paths) {
|
||||
if (new File(path + filename).exists())
|
||||
return path + filename;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void close() {
|
||||
driver.close();
|
||||
}
|
||||
|
||||
public void navigateTo(String url) {
|
||||
driver.navigate().to(url);
|
||||
}
|
||||
|
||||
public void clickElement(WebElement element) {
|
||||
element.click();
|
||||
}
|
||||
|
||||
public WebDriver getDriver() {
|
||||
return driver;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package main.java.com.baeldung.selenium.models;
|
||||
|
||||
import main.java.com.baeldung.selenium.config.SeleniumConfig;
|
||||
import main.java.com.baeldung.selenium.pages.BaeldungAboutPage;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
public class BaeldungAbout {
|
||||
|
||||
private SeleniumConfig config;
|
||||
|
||||
public BaeldungAbout(SeleniumConfig config) {
|
||||
this.config = config;
|
||||
PageFactory.initElements(config.getDriver(), BaeldungAboutPage.class);
|
||||
}
|
||||
|
||||
public void navigateTo() {
|
||||
config.navigateTo("http://www.baeldung.com/about/");
|
||||
}
|
||||
|
||||
public String getPageTitle() {
|
||||
return BaeldungAboutPage.title.getText();
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package main.java.com.baeldung.selenium.pages;
|
||||
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
public class BaeldungAboutPage {
|
||||
|
||||
@FindBy(css = ".page-header > h1")
|
||||
public static WebElement title;
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package main.java.com.baeldung.selenium.pages;
|
||||
|
||||
import main.java.com.baeldung.selenium.config.SeleniumConfig;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
public class BaeldungHomePage {
|
||||
|
||||
private SeleniumConfig config;
|
||||
@FindBy(css=".header--menu > a")
|
||||
private WebElement title;
|
||||
@FindBy(css = ".menu-start-here > a")
|
||||
private WebElement startHere;
|
||||
|
||||
public BaeldungHomePage(SeleniumConfig config) {
|
||||
this.config = config;
|
||||
PageFactory.initElements(this.config.getDriver(), this);
|
||||
}
|
||||
|
||||
public void navigate() {
|
||||
this.config.navigateTo("http://www.baeldung.com/");
|
||||
}
|
||||
|
||||
public String getPageTitle() {
|
||||
return title.getAttribute("title");
|
||||
}
|
||||
|
||||
public StartHerePage clickOnStartHere() {
|
||||
config.clickElement(startHere);
|
||||
|
||||
StartHerePage startHerePage = new StartHerePage(config);
|
||||
PageFactory.initElements(config.getDriver(), startHerePage);
|
||||
|
||||
return startHerePage;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package main.java.com.baeldung.selenium.pages;
|
||||
|
||||
import main.java.com.baeldung.selenium.config.SeleniumConfig;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
public class StartHerePage {
|
||||
|
||||
private SeleniumConfig config;
|
||||
|
||||
@FindBy(css = ".page-title")
|
||||
private WebElement title;
|
||||
|
||||
public StartHerePage(SeleniumConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public String getPageTitle() {
|
||||
return title.getText();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user