From d9a4224317c2ef5c5dae969003c6342a530d4500 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 10 May 2019 19:15:22 +0400 Subject: [PATCH] #103 add attach article --- src/test/java/IndexConferenceTest.java | 33 ++++++++++++++++++-- src/test/java/conference/ConferencePage.java | 20 +++++++++++- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index 8408029..4c40d7d 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -10,6 +10,7 @@ import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -117,14 +118,14 @@ public class IndexConferenceTest extends TestTemplate { conferencesPage.getConferenceFirst(); String conferenceId = conferencePage.getId(); - Integer membersCount = conferencePage.getMemperCount(); + Integer membersCount = conferencePage.getMemberCount(); conferencePage.clickTakePartBut(); conferencePage.clickSaveBut(); getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); - Assert.assertTrue(membersCount + 1 == conferencePage.getMemperCount() + Assert.assertTrue(membersCount + 1 == conferencePage.getMemberCount() && conferencePage.getTakePartButDisabledValue().equals("true")); } @@ -147,4 +148,32 @@ public class IndexConferenceTest extends TestTemplate { Assert.assertTrue(deadlineCount - 1 == conferencePage.getDeadlineCount()); } + + @Test + public void testAttachArticle() { + 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 paperCount = conferencePage.getPaperCount(); + + conferencePage.showAllowToAttachArticles(); + WebElement paper = conferencePage.selectPaper(); + String paperName = paper.findElement(By.className("text")).getText(); + conferencePage.clickSaveBut(); + + getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); + + Assert.assertTrue(paperCount + 1 == conferencePage.getPaperCount() + && conferencePage.getPapers() + .stream() + .anyMatch(webElement -> webElement + .findElement(By.className("paper-name")) + .findElements(By.tagName("span")) + .get(1).getText().equals(paperName))); + } } diff --git a/src/test/java/conference/ConferencePage.java b/src/test/java/conference/ConferencePage.java index d51e7b9..02fa0fc 100644 --- a/src/test/java/conference/ConferencePage.java +++ b/src/test/java/conference/ConferencePage.java @@ -60,11 +60,29 @@ public class ConferencePage extends PageObject { return driver.findElement(By.id("take-part")).getAttribute("disabled"); } - public Integer getMemperCount() { + public Integer getMemberCount() { return driver.findElements(By.className("member")).size(); } public void clickDeleteDeadlineBut() { driver.findElement(By.xpath("//*[@id=\"deadlines\"]/div/input[4]")).click(); } + + public void showAllowToAttachArticles() { + driver.findElement(By.cssSelector("button[data-id=\"paperIds\"]")).click(); + } + + public List getPapers() { + return driver.findElements(By.className("paper")); + } + + public Integer getPaperCount() { + return driver.findElements(By.className("paper")).size(); + } + + public WebElement selectPaper() { + WebElement webElement = driver.findElement(By.xpath("//*[@id=\"conference-form\"]/div/div[2]/div[5]/div/div/div[2]/ul/li[1]/a")); + webElement.click(); + return webElement; + } } \ No newline at end of file