-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4775728
Showing
8 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
release.properties | ||
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties | ||
# https://github.com/takari/maven-wrapper#usage-without-binary-jar | ||
.mvn/wrapper/maven-wrapper.jar | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.example</groupId> | ||
<artifactId>rv-zalenium</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<testng.version>7.1.0</testng.version> | ||
<selenium.version>3.141.59</selenium.version> | ||
<java.client.version>7.3.0</java.client.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>${testng.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.seleniumhq.selenium</groupId> | ||
<artifactId>selenium-java</artifactId> | ||
<version>${selenium.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.appium</groupId> | ||
<artifactId>java-client</artifactId> | ||
<version>${java.client.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package pages; | ||
|
||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.FindBy; | ||
import org.openqa.selenium.support.PageFactory; | ||
import org.openqa.selenium.support.ui.ExpectedConditions; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
/** | ||
* @author Razvan Vancea | ||
*/ | ||
public class GooglePage { | ||
|
||
private WebDriver driver; | ||
private WebDriverWait wait; | ||
|
||
@FindBy(name = "q") | ||
private WebElement searchTextField; | ||
|
||
@FindBy(name = "btnK") | ||
private WebElement searchBtn; | ||
|
||
public GooglePage(WebDriver driver){ | ||
this.driver = driver; | ||
wait = new WebDriverWait(driver, 15); | ||
PageFactory.initElements(driver, this); | ||
} | ||
|
||
public void goTo(String url){ | ||
driver.get(url); | ||
wait.until(ExpectedConditions.visibilityOf(searchBtn)); | ||
} | ||
|
||
public void searchFor(String text){ | ||
wait.until(ExpectedConditions.elementToBeClickable(searchTextField)); | ||
searchTextField.click(); | ||
searchTextField.sendKeys(text); | ||
} | ||
|
||
public void clickSearchBtn(){ | ||
searchBtn.click(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package pages; | ||
|
||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.FindBy; | ||
import org.openqa.selenium.support.PageFactory; | ||
import org.openqa.selenium.support.ui.ExpectedConditions; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
/** | ||
* @author Razvan Vancea | ||
*/ | ||
public class GoogleResultsPage { | ||
private WebDriver driver; | ||
private WebDriverWait wait; | ||
|
||
@FindBy(xpath = "//h3[@text()='Zalenium - A flexible and scalable Selenium Grid.']") | ||
private WebElement zaleniumTextResult; | ||
|
||
public GoogleResultsPage(WebDriver driver){ | ||
this.driver = driver; | ||
wait = new WebDriverWait(driver, 30); | ||
PageFactory.initElements(driver, this); | ||
} | ||
|
||
public void clickZaleniumResult(){ | ||
wait.until(ExpectedConditions.visibilityOf(zaleniumTextResult)); | ||
zaleniumTextResult.click(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package pages; | ||
|
||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.FindBy; | ||
import org.openqa.selenium.support.PageFactory; | ||
import org.openqa.selenium.support.ui.ExpectedConditions; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
/** | ||
* @author Razvan Vancea | ||
*/ | ||
public class ZaleniumPage { | ||
|
||
private WebDriver driver; | ||
private WebDriverWait wait; | ||
|
||
@FindBy(xpath = "//a[@text()='Docker']") | ||
private WebElement dockerLink; | ||
|
||
@FindBy(xpath = "//h3[@text()='Starting Zalenium']") | ||
private WebElement startingZaleniumText; | ||
|
||
public ZaleniumPage(WebDriver driver){ | ||
this.driver = driver; | ||
wait = new WebDriverWait(driver, 30); | ||
PageFactory.initElements(driver, this); | ||
} | ||
|
||
public void clickDockerLink(){ | ||
wait.until(ExpectedConditions.visibilityOf(dockerLink)); | ||
dockerLink.click(); | ||
} | ||
|
||
public WebElement getStartingZaleniumText(){ | ||
wait.until(ExpectedConditions.visibilityOf(startingZaleniumText)); | ||
return startingZaleniumText; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.firefox.FirefoxOptions; | ||
import org.openqa.selenium.remote.DesiredCapabilities; | ||
import org.openqa.selenium.remote.RemoteWebDriver; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
import org.testng.annotations.AfterTest; | ||
import org.testng.annotations.BeforeTest; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
/** | ||
* @author Razvan Vancea | ||
*/ | ||
public class BaseTest { | ||
protected WebDriver driver; | ||
|
||
@BeforeTest | ||
public void setupDriver(){ | ||
DesiredCapabilities capabilities; | ||
capabilities = DesiredCapabilities.chrome(); | ||
String host = "http://localhost:4444/wd/hub"; | ||
try { | ||
this.driver = new RemoteWebDriver(new URL(host), capabilities); | ||
} catch (MalformedURLException e){ | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@AfterTest | ||
public void tearDown(){ | ||
this.driver.quit(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
import pages.GooglePage; | ||
import pages.GoogleResultsPage; | ||
import pages.ZaleniumPage; | ||
|
||
/** | ||
* @author Razvan Vancea | ||
*/ | ||
public class ZaleniumTest extends BaseTest { | ||
|
||
|
||
@Test | ||
public void assertDocumentation(){ | ||
GooglePage googlePage = new GooglePage(driver); | ||
GoogleResultsPage googleResultsPage = new GoogleResultsPage(driver); | ||
ZaleniumPage zaleniumPage = new ZaleniumPage(driver); | ||
|
||
googlePage.goTo("https://www.google.ro"); | ||
googlePage.searchFor("Zalenium docs"); | ||
googlePage.clickSearchBtn(); | ||
googleResultsPage.clickZaleniumResult(); | ||
zaleniumPage.clickDockerLink(); | ||
Assert.assertTrue(zaleniumPage.getStartingZaleniumText().isDisplayed()); | ||
} | ||
} |