From 253f4b4aad96dad266fb62fb1180bea11055e5dd Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 10 May 2019 17:03:47 +0400 Subject: [PATCH] #103 add check new deadline --- src/test/java/IndexConferenceTest.java | 29 +++++++++++++++++ src/test/java/conference/ConferencePage.java | 33 +++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index b3a4118..7f8ee57 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -9,6 +9,7 @@ import org.assertj.core.api.Assertions; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; +import org.openqa.selenium.By; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -76,5 +77,33 @@ public class IndexConferenceTest extends TestTemplate { .anyMatch(webElement -> webElement.getText().equals(newConferenceName))); } + @Test + public void testAddDeadlineAndSave() { + Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); + getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); + ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey()); + ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey()); + + conferencesPage.getConferenceFirst(); + String conferenceId = conferencePage.getId(); + Integer deadlineCount = conferencePage.getDeadlineCount(); + + String description = "test"; + String date = "09.09.2019"; + String dateValue = "2019-09-09"; + conferencePage.clickAddDeadlineBut(); + conferencePage.setDeadlineDescription(description, deadlineCount); + conferencePage.setDeadlineDate(date, deadlineCount); + conferencePage.clickSaveBut(); + + getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); + + Assert.assertTrue(conferencePage.getDeadlineList() + .stream() + .anyMatch(webElement -> { + return webElement.findElement(By.className("deadline-text")).getAttribute("value").equals(description) + && webElement.findElement(By.cssSelector("input[type=\"date\"]")).getAttribute("value").equals(dateValue); + })); + } } diff --git a/src/test/java/conference/ConferencePage.java b/src/test/java/conference/ConferencePage.java index 48362e0..00d9585 100644 --- a/src/test/java/conference/ConferencePage.java +++ b/src/test/java/conference/ConferencePage.java @@ -2,6 +2,9 @@ package conference; import core.PageObject; import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import java.util.List; public class ConferencePage extends PageObject { @@ -9,10 +12,18 @@ public class ConferencePage extends PageObject { return driver.findElement(By.tagName("h3")).getText(); } + public String getId() { + return driver.findElement(By.id("id")).getAttribute("value"); + } + public void setName(String name) { driver.findElement(By.id("title")).sendKeys(name); } + public String getName() { + return driver.findElement(By.id("title")).getAttribute("value"); + } + public void clearName() { driver.findElement(By.id("title")).clear(); } @@ -20,4 +31,24 @@ public class ConferencePage extends PageObject { public void clickSaveBut() { driver.findElement(By.id("send-message-button")).click(); } -} + + public void clickAddDeadlineBut() { + driver.findElement(By.id("addDeadline")).click(); + } + + public List getDeadlineList() { + return driver.findElements(By.className("deadline")); + } + + public Integer getDeadlineCount() { + return driver.findElements(By.className("deadline")).size(); + } + + public void setDeadlineDescription(String description, Integer i) { + driver.findElement(By.id(String.format("deadlines%d.description", i))).sendKeys(description); + } + + public void setDeadlineDate(String date, Integer i) { + driver.findElement(By.id(String.format("deadlines%d.date", i))).sendKeys(date); + } +} \ No newline at end of file