series - elemn
This commit is contained in:
24
selenidetraining/src/test/java/base/TestBase.java
Normal file
24
selenidetraining/src/test/java/base/TestBase.java
Normal file
@ -0,0 +1,24 @@
|
||||
package base;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.chrome.ChromeOptions;
|
||||
|
||||
public class TestBase {
|
||||
protected WebDriver driver;
|
||||
protected final String BASE_URL = "http://localhost:8888";
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
//System.setProperty("webdriver.chrome.driver", "src/test/resources/drivers/mac/chromedriver75_mac");
|
||||
driver = new ChromeDriver();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
driver.close();
|
||||
driver.quit();
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package pages;
|
||||
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.Keys;
|
||||
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.Select;
|
||||
|
||||
public class SavingsCalculatorPage {
|
||||
@FindBy(id = "emailInput")
|
||||
private WebElement emailInput;
|
||||
|
||||
@FindBy(id = "yearsInput")
|
||||
private WebElement yearsInput;
|
||||
|
||||
@FindBy(id = "oneTimeInvestmentInput")
|
||||
private WebElement oneTimeInvestmentInput;
|
||||
|
||||
@FindBy(id = "fundSelect")
|
||||
private WebElement fundSelect;
|
||||
|
||||
@FindBy(css = "button.btn")
|
||||
private WebElement applyButton;
|
||||
|
||||
@FindBy(css = "div.result")
|
||||
private WebElement resultElement;
|
||||
|
||||
@FindBy(css = "ul.saving-list div.saving-detail")
|
||||
private WebElement mostRecentSavingsDetail;
|
||||
|
||||
private WebDriver pageDriver;
|
||||
|
||||
public SavingsCalculatorPage(WebDriver driver) {
|
||||
this.pageDriver = driver;
|
||||
PageFactory.initElements(driver, this);
|
||||
}
|
||||
|
||||
public void enterEmail(String email) {
|
||||
emailInput.clear();
|
||||
emailInput.sendKeys(email);
|
||||
emailInput.sendKeys(Keys.TAB);
|
||||
}
|
||||
|
||||
public void enterYears(int years) {
|
||||
yearsInput.clear();
|
||||
yearsInput.sendKeys(String.valueOf(years));
|
||||
}
|
||||
|
||||
public void enterOneTimeInvestment(String amount) {
|
||||
oneTimeInvestmentInput.clear();
|
||||
oneTimeInvestmentInput.sendKeys(amount);
|
||||
}
|
||||
|
||||
public void selectFund(String fundToSelect) {
|
||||
new Select(fundSelect).selectByVisibleText(fundToSelect);
|
||||
}
|
||||
|
||||
public void applyForSaving() {
|
||||
applyButton.click();
|
||||
}
|
||||
|
||||
|
||||
public WebElement getCalculatedTotalIncomeElement() {
|
||||
return resultElement.findElement(By.xpath("./div[1]/p"));
|
||||
}
|
||||
|
||||
public WebElement getCalculatedInterestIncomeElement() {
|
||||
return pageDriver.findElement(By.cssSelector("div.result > div:nth-child(2) p"));
|
||||
}
|
||||
|
||||
public WebElement getCalculatedRiskElement() {
|
||||
return resultElement.findElement(By.xpath("./div[3]/p"));
|
||||
}
|
||||
|
||||
public WebElement getRecentRequestDetail() {
|
||||
return mostRecentSavingsDetail;
|
||||
}
|
||||
|
||||
public WebElement getApplyButton() {
|
||||
return applyButton;
|
||||
}
|
||||
|
||||
|
||||
public WebElement getEmailInputWrapper(){
|
||||
return pageDriver.findElement(By.xpath("//input[@id='emailInput']/.."));
|
||||
}
|
||||
}
|
18
selenidetraining/src/test/java/suites/TestSuite.java
Normal file
18
selenidetraining/src/test/java/suites/TestSuite.java
Normal file
@ -0,0 +1,18 @@
|
||||
package suites;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import tests.*;
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
FellowshipTest.class,
|
||||
GosslingatorTest.class,
|
||||
RandomTableTest.class,
|
||||
SavingsCalculatorTest.class,
|
||||
SortingHatTest.class,
|
||||
WaitForItTest.class,
|
||||
SpelleologyTest.class
|
||||
})
|
||||
public class TestSuite {
|
||||
}
|
103
selenidetraining/src/test/java/tests/FellowshipTest.java
Normal file
103
selenidetraining/src/test/java/tests/FellowshipTest.java
Normal file
@ -0,0 +1,103 @@
|
||||
package tests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import base.TestBase;
|
||||
|
||||
public class FellowshipTest extends TestBase {
|
||||
|
||||
@Before
|
||||
public void openPage() {
|
||||
driver.get(BASE_URL + "/fellowship.php");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldContainNameForEachFellow() {
|
||||
List<WebElement> fellowElements = getFellowElements();
|
||||
|
||||
for (WebElement fellowElement : fellowElements) {
|
||||
Assert.assertFalse(fellowElement.findElement(By.cssSelector("h1")).getText().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldContainSpecifiedFellows() {
|
||||
List<WebElement> fellowElements = getFellowElements();
|
||||
List<String> fellowNames = new ArrayList<String>();
|
||||
|
||||
for (WebElement fellowElement : fellowElements) {
|
||||
System.out.println(fellowElement.findElement(By.cssSelector("h1")).getText());
|
||||
fellowNames.add(fellowElement.findElement(By.cssSelector("h1")).getText());
|
||||
}
|
||||
System.out.println(fellowNames);
|
||||
Assert.assertTrue(fellowNames.contains("Gandalf"));
|
||||
Assert.assertTrue(fellowNames.contains("Aragorn"));
|
||||
Assert.assertTrue(fellowNames.contains("Frodo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldDisplayMessageComplete() {
|
||||
List<String> fellowsToSelect = new ArrayList<String>();
|
||||
fellowsToSelect.add("Gandalf");
|
||||
fellowsToSelect.add("Aragorn");
|
||||
fellowsToSelect.add("Legolas");
|
||||
fellowsToSelect.add("Frodo");
|
||||
|
||||
for (String fellowToSelect : fellowsToSelect) {
|
||||
selectFellow(fellowToSelect);
|
||||
}
|
||||
|
||||
Assert.assertEquals("Complete", driver.findElement(By.cssSelector("div.points-left h3")).getText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldDisplayPointsForEachFellow() {
|
||||
List<WebElement> displayedFellows = getFellowElements();
|
||||
for (WebElement displayedFellow : displayedFellows) {
|
||||
|
||||
String actualPoints = displayedFellow.findElement(By.cssSelector("div.fellow-points h2")).getText();
|
||||
|
||||
Assert.assertFalse(actualPoints.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldHighlightFellows() {
|
||||
List<String> fellowsToSelect = new ArrayList<String>();
|
||||
fellowsToSelect.add("Gandalf");
|
||||
fellowsToSelect.add("Aragorn");
|
||||
fellowsToSelect.add("Legolas");
|
||||
fellowsToSelect.add("Frodo");
|
||||
|
||||
for (String fellowToSelect : fellowsToSelect) {
|
||||
selectFellow(fellowToSelect);
|
||||
}
|
||||
|
||||
List<String> higlightedFellows =
|
||||
driver.findElements(By.xpath("//ul[contains(@class,'list-of-fellows')]/li/div[contains(@class,'active')]//h1"))
|
||||
.stream()
|
||||
.map(WebElement::getText)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (String higlightedFellow : higlightedFellows) {
|
||||
Assert.assertTrue(fellowsToSelect.contains(higlightedFellow));
|
||||
}
|
||||
}
|
||||
|
||||
private void selectFellow(String fellowName) {
|
||||
driver.findElement(By.xpath("//h1[contains(text(),'" + fellowName + "')]")).click();
|
||||
}
|
||||
|
||||
private List<WebElement> getFellowElements() {
|
||||
return driver.findElements(By.cssSelector("ul.list-of-fellows li"));
|
||||
}
|
||||
}
|
77
selenidetraining/src/test/java/tests/GosslingatorTest.java
Normal file
77
selenidetraining/src/test/java/tests/GosslingatorTest.java
Normal file
@ -0,0 +1,77 @@
|
||||
package tests;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.chrome.ChromeOptions;
|
||||
|
||||
public class GosslingatorTest {
|
||||
|
||||
private WebDriver driver;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
//System.setProperty("webdriver.chrome.driver", "src/test/resources/drivers/chromedriver75_mac");
|
||||
driver = new ChromeDriver();
|
||||
driver.get("http://localhost:8888/gosslingator.php");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldDisplayTitle() {
|
||||
Assert.assertEquals("GOSLINGATE ME", driver.findElement(By.cssSelector(".ryan-title")).getText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldAddOneRyan() {
|
||||
driver.findElement(By.id("addRyan")).click();
|
||||
|
||||
String actualNumberOfRyans = driver.findElement(By.id("ryanCounter")).getText();
|
||||
Assert.assertEquals("1", actualNumberOfRyans);
|
||||
|
||||
System.out.println("Number of ryans: " + driver.findElement(By.cssSelector("div.ryan-counter h2")).getText());
|
||||
Assert.assertEquals("ryan", driver.findElement(By.cssSelector("div.ryan-counter h3")).getText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldTwoRyans() {
|
||||
driver.findElement(By.id("addRyan")).click();
|
||||
driver.findElement(By.id("addRyan")).click();
|
||||
|
||||
String actualNumberOfRyans = driver.findElement(By.id("ryanCounter")).getText();
|
||||
String actualRyanDescription = driver.findElement(By.cssSelector("div.ryan-counter h3")).getText();
|
||||
|
||||
Assert.assertEquals("2", actualNumberOfRyans);
|
||||
Assert.assertEquals("ryans", actualRyanDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldDisplayWarningMessage() {
|
||||
WebElement addRyanButton = driver.findElement(By.id("addRyan"));
|
||||
for (int i = 0; i < 50; i++) {
|
||||
addRyanButton.click();
|
||||
}
|
||||
Assert.assertEquals(
|
||||
"NUMBER OF\n" +
|
||||
"RYANS\n" +
|
||||
"IS TOO DAMN\n" +
|
||||
"HIGH",
|
||||
driver.findElement(By.cssSelector("h1.tooManyRyans")).getText()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldDisplayNoRyanOnPageOpen() {
|
||||
Assert.assertEquals(0, driver.findElements(By.cssSelector("img")).size());
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
driver.close();
|
||||
driver.quit();
|
||||
}
|
||||
}
|
47
selenidetraining/src/test/java/tests/RandomTableTest.java
Normal file
47
selenidetraining/src/test/java/tests/RandomTableTest.java
Normal file
@ -0,0 +1,47 @@
|
||||
package tests;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import base.TestBase;
|
||||
|
||||
public class RandomTableTest extends TestBase {
|
||||
@Before
|
||||
public void openPage() {
|
||||
//1.otvorit stranku
|
||||
driver.get(BASE_URL + "/tabulka.php");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldContainDataForEachRow() {
|
||||
for (WebElement tableRow : getRows()) {
|
||||
Assert.assertFalse(tableRow.getText().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldContainNameForEachRow() {
|
||||
List<WebElement> tableRows = getRows();
|
||||
for (WebElement tableRow : tableRows) {
|
||||
tableRow.findElement(By.cssSelector("td:nth-child(2)"));
|
||||
WebElement rowName = tableRow.findElement(By.xpath("./td[2]"));
|
||||
Assert.assertFalse(rowName.getText().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldScrollToLastElement() {
|
||||
WebElement lastRow = driver.findElement(By.cssSelector("table > tbody > tr:last-child"));
|
||||
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", lastRow);
|
||||
}
|
||||
|
||||
private List<WebElement> getRows() {
|
||||
return driver.findElements(By.cssSelector("table tbody tr"));
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package tests;
|
||||
|
||||
import base.TestBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.interactions.Actions;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
import pages.SavingsCalculatorPage;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.openqa.selenium.By.cssSelector;
|
||||
|
||||
public class SavingsCalculatorTest extends TestBase {
|
||||
private SavingsCalculatorPage savingsCalculatorPage;
|
||||
|
||||
@Before
|
||||
public void openPage() {
|
||||
driver.get(BASE_URL.concat("/savingscalculator.php"));
|
||||
savingsCalculatorPage = new SavingsCalculatorPage(driver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldEnableApplyButton() {
|
||||
savingsCalculatorPage.selectFund("Hoggwart's Fund");
|
||||
savingsCalculatorPage.enterOneTimeInvestment("15000");
|
||||
savingsCalculatorPage.enterYears(20);
|
||||
savingsCalculatorPage.enterEmail("info@furbo.sk");
|
||||
|
||||
assertTrue(savingsCalculatorPage.getApplyButton().isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldDisplayCalculatedAmounts() {
|
||||
savingsCalculatorPage.selectFund("Hoggwart's Fund");
|
||||
savingsCalculatorPage.enterOneTimeInvestment("15000");
|
||||
savingsCalculatorPage.enterYears(20);
|
||||
savingsCalculatorPage.enterEmail("info@furbo.sk");
|
||||
|
||||
assertFalse(savingsCalculatorPage.getCalculatedTotalIncomeElement().getText().isEmpty());
|
||||
assertFalse(savingsCalculatorPage.getCalculatedInterestIncomeElement().getText().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldDisplayCalculatedRisk() {
|
||||
savingsCalculatorPage.selectFund("Hoggwart's Fund");
|
||||
savingsCalculatorPage.enterOneTimeInvestment("15000");
|
||||
savingsCalculatorPage.enterYears(20);
|
||||
savingsCalculatorPage.enterEmail("info@furbo.sk");
|
||||
|
||||
assertFalse(savingsCalculatorPage.getCalculatedRiskElement().getText().isEmpty());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void itShouldContainFundNameInNewRequest() {
|
||||
String fundToSelect = "Hoggwart's Fund";
|
||||
|
||||
savingsCalculatorPage.selectFund(fundToSelect);
|
||||
savingsCalculatorPage.enterOneTimeInvestment("25000");
|
||||
savingsCalculatorPage.enterYears(20);
|
||||
savingsCalculatorPage.enterEmail("info@furbo.sk");
|
||||
|
||||
savingsCalculatorPage.applyForSaving();
|
||||
|
||||
assertEquals(
|
||||
fundToSelect,
|
||||
savingsCalculatorPage.getRecentRequestDetail().findElement(cssSelector("p.fund-description")).getText()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldDisplayErrorMessageWhenEmailIsInvalid() {
|
||||
savingsCalculatorPage.enterEmail("invalid");
|
||||
assertTrue(savingsCalculatorPage.getEmailInputWrapper().getAttribute("class").contains("error"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldHighlightNewRequestOnHover() throws InterruptedException {
|
||||
savingsCalculatorPage.selectFund("Hoggwart's Fund");
|
||||
savingsCalculatorPage.enterOneTimeInvestment("15000");
|
||||
savingsCalculatorPage.enterYears(20);
|
||||
savingsCalculatorPage.enterEmail("info@furbo.sk");
|
||||
savingsCalculatorPage.applyForSaving();
|
||||
|
||||
Actions action = new Actions(driver);
|
||||
WebElement we = driver.findElement(By.cssSelector("div.saving-detail"));
|
||||
action.moveToElement(we).build().perform();
|
||||
Thread.sleep(300);
|
||||
assertEquals("rgba(4, 102, 156, 1)", we.getCssValue("background-color"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
23
selenidetraining/src/test/java/tests/SortingHatTest.java
Normal file
23
selenidetraining/src/test/java/tests/SortingHatTest.java
Normal file
@ -0,0 +1,23 @@
|
||||
package tests;
|
||||
|
||||
import base.TestBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
public class SortingHatTest extends TestBase {
|
||||
|
||||
|
||||
@Test
|
||||
public void itShouldDisplayNameOfHouse() {
|
||||
driver.get(BASE_URL + "/sortinghat.php");
|
||||
driver.findElement(By.cssSelector("button")).click();
|
||||
new WebDriverWait(driver, 10)
|
||||
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("img.loading")));
|
||||
new WebDriverWait(driver, 10)
|
||||
.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("img.loading")));
|
||||
Assert.assertFalse(driver.findElement(By.cssSelector("p.result")).getText().isEmpty());
|
||||
}
|
||||
}
|
68
selenidetraining/src/test/java/tests/SpelleologyTest.java
Normal file
68
selenidetraining/src/test/java/tests/SpelleologyTest.java
Normal file
@ -0,0 +1,68 @@
|
||||
package tests;
|
||||
|
||||
import base.TestBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SpelleologyTest extends TestBase {
|
||||
|
||||
@Before
|
||||
public void openPage() {
|
||||
driver.get(BASE_URL + "/spelleology.php");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldContainSpells() {
|
||||
String[] spellsToBePresent = {
|
||||
"counters sonorus",
|
||||
"erases memories",
|
||||
"counterspells",
|
||||
"controls a person – unforgivable"
|
||||
};
|
||||
|
||||
new WebDriverWait(driver, 10)
|
||||
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("ul.spells li")));
|
||||
List<String> displayedSpells = driver.findElements(By.cssSelector("ul.spells li"))
|
||||
.stream()
|
||||
.map(WebElement::getText)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (String spellToCheck : spellsToBePresent) {
|
||||
Assert.assertTrue(displayedSpells.contains(spellToCheck));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldDisplayTortureSpell() {
|
||||
new WebDriverWait(driver, 10)
|
||||
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("ul.spells li")));
|
||||
List<WebElement> spellElements = driver.findElements(By.cssSelector("ul.spells li"));
|
||||
|
||||
for (WebElement spellElement : spellElements) {
|
||||
if (spellElement.getText().equals("tortures a person")) {
|
||||
spellElement.click();
|
||||
}
|
||||
}
|
||||
new WebDriverWait(driver, 10)
|
||||
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div.modal-container")));
|
||||
WebElement modal = driver.findElement(By.cssSelector("div.modal-container"));
|
||||
Assert.assertTrue(modal.getText().contains("Crucio"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldFilterSpells() {
|
||||
driver.findElement(By.cssSelector("input")).sendKeys("tortures a person");
|
||||
new WebDriverWait(driver, 10).until(ExpectedConditions
|
||||
.numberOfElementsToBe(By.cssSelector("ul.spells li"), 1));
|
||||
Assert.assertEquals(driver.findElements(By.cssSelector("ul.spells li")).size(), 1);
|
||||
}
|
||||
|
||||
}
|
49
selenidetraining/src/test/java/tests/WaitForItTest.java
Normal file
49
selenidetraining/src/test/java/tests/WaitForItTest.java
Normal file
@ -0,0 +1,49 @@
|
||||
package tests;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import base.TestBase;
|
||||
|
||||
public class WaitForItTest extends TestBase {
|
||||
|
||||
@Before
|
||||
public void openPage() {
|
||||
driver.get(BASE_URL + "/waitforit.php");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void waitForValue() {
|
||||
String expectedText = "dary !!!";
|
||||
driver.findElement(By.id("startWaitForText")).click();
|
||||
WebElement input = driver.findElement(By.id("waitForTextInput"));
|
||||
|
||||
new WebDriverWait(driver, 5)
|
||||
.until(ExpectedConditions.attributeToBe(input, "value", expectedText));
|
||||
|
||||
Assert.assertEquals(expectedText, input.getAttribute("value"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void waitForClass() {
|
||||
driver.findElement(By.id("startWaitForProperty")).click();
|
||||
|
||||
new WebDriverWait(driver, 10)
|
||||
.until(ExpectedConditions.attributeContains(By.id("waitForProperty"),"class","error"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldDisplayResponseTimeMessage() {
|
||||
driver.findElement(By.id("startWaitForText")).click();
|
||||
|
||||
new WebDriverWait(driver, 10).until(ExpectedConditions.textToBePresentInElement(
|
||||
driver.findElement(By.cssSelector("div.current-wait-time")),
|
||||
"Response time"));
|
||||
Assert.assertTrue(driver.findElement(By.cssSelector("div.current-wait-time")).getText().contains("Response time"));
|
||||
}
|
||||
}
|
16
selenidetraining/src/test/java/utils/DataUtils.java
Normal file
16
selenidetraining/src/test/java/utils/DataUtils.java
Normal file
@ -0,0 +1,16 @@
|
||||
package utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DataUtils {
|
||||
public static List<String> getExpectedSpells() throws FileNotFoundException {
|
||||
FileReader fileReader = new FileReader(new File("src/test/resources/testData/spells.txt"));
|
||||
BufferedReader br = new BufferedReader(fileReader);
|
||||
return br.lines().collect(Collectors.toList());
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
91
selenidetraining/src/test/resources/testData/spells.txt
Normal file
91
selenidetraining/src/test/resources/testData/spells.txt
Normal file
@ -0,0 +1,91 @@
|
||||
summons an object
|
||||
shoots water from wand
|
||||
opens locked objects
|
||||
clears the target's airway
|
||||
reveals invisible ink
|
||||
murders opponent
|
||||
turns small objects into birds
|
||||
launches birds from your wand
|
||||
strengthens an enclosure from enemies
|
||||
magically locks door
|
||||
explodes flames on target
|
||||
confuses opponent
|
||||
damages opponents eyesight
|
||||
tortures a person
|
||||
digs out materials
|
||||
counters `prior incatato`
|
||||
enlarges teeth
|
||||
blasts holes through walls and floors
|
||||
splits seams
|
||||
opens `one eyed witch` hump
|
||||
makes objects hard
|
||||
enlarges and item
|
||||
counters stupefy
|
||||
heals minor injuries
|
||||
erects things
|
||||
creates a patronus
|
||||
disarms your opponent
|
||||
makes objects explode
|
||||
creates bandages
|
||||
hides a secret within someone
|
||||
stops any current spells
|
||||
allows user to write on objects
|
||||
knocks an object backwards
|
||||
produces boils on opponent
|
||||
duplicates an object
|
||||
turns stairs into ramps
|
||||
reveals humans nearby
|
||||
cures werewolves (at least according to lockhart)
|
||||
renders target immobile.
|
||||
slows an advancing object
|
||||
controls a person – unforgivable
|
||||
makes an object repel water
|
||||
ties someone up
|
||||
starts a fire
|
||||
glues opponent's tongue to roof of mouth
|
||||
allows the caster to delve into the mind of the victim
|
||||
hangs victim upside down by feet
|
||||
counterspells
|
||||
locks opponents legs
|
||||
creates light at wand tip
|
||||
causes weather effect spells to stop
|
||||
moves objects with wand
|
||||
moves unconscious bodies
|
||||
conjures the dark mark
|
||||
prevents nearby people from listening to conversations
|
||||
counters lumos
|
||||
erases memories
|
||||
blindfolds the victim
|
||||
makes conjured items attack
|
||||
conjures a bunch of flowers
|
||||
packs a trunk (suitcase)
|
||||
removes pixies (maybe)
|
||||
binds body – unforgivable
|
||||
animates statues and armor suits
|
||||
makes wand act like a compass
|
||||
echoes most recent spells, result when brother wands duel
|
||||
reveals a wands last spell / cast
|
||||
causes spells to reflect back to the sender.
|
||||
protects one from dark magic
|
||||
protects area
|
||||
counters sonorus
|
||||
returns items to original size. counters engorgio
|
||||
blasts solid objects aside
|
||||
releases user from binding
|
||||
cures unconsciousness
|
||||
repairs things
|
||||
keeps muggles away
|
||||
tickles opponent
|
||||
turns boggart into ridiculous form so you can laugh it away
|
||||
protects against hexes
|
||||
destroys ectoplasm (remains of ghosts)
|
||||
causes wounds as if slashed by a sword
|
||||
produces snake
|
||||
silences victim
|
||||
amplifies voice
|
||||
reveals hidden secrets or magical properties
|
||||
knocks out opponent
|
||||
forces opponent to dance
|
||||
cleans up messes
|
||||
unsticks an object
|
||||
makes on object fly
|
Reference in New Issue
Block a user