From 961fdf939759265df386f113444593d9586b4b61 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 10 May 2019 15:07:47 +0400 Subject: [PATCH 01/17] #70 added conference class, added create method test --- src/test/java/IndexConferenceTest.java | 59 +++++++++++++++++++ src/test/java/conference/ConferencePage.java | 19 ++++++ .../conference/ConferencesDashboardPage.java | 11 ++++ src/test/java/conference/ConferencesPage.java | 19 ++++++ 4 files changed, 108 insertions(+) create mode 100644 src/test/java/IndexConferenceTest.java create mode 100644 src/test/java/conference/ConferencePage.java create mode 100644 src/test/java/conference/ConferencesDashboardPage.java create mode 100644 src/test/java/conference/ConferencesPage.java diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java new file mode 100644 index 0000000..9adf2f5 --- /dev/null +++ b/src/test/java/IndexConferenceTest.java @@ -0,0 +1,59 @@ +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; +import conference.ConferencePage; +import conference.ConferencesDashboardPage; +import conference.ConferencesPage; +import core.PageObject; +import core.TestTemplate; +import org.assertj.core.api.Assertions; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import ru.ulstu.NgTrackerApplication; +import ru.ulstu.configuration.ApplicationProperties; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = NgTrackerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) +public class IndexConferenceTest extends TestTemplate { + private final Map> navigationHolder = ImmutableMap.of( + new ConferencesPage(), Arrays.asList("КОНФЕРЕНЦИИ", "/conferences/conferences"), + new ConferencePage(), Arrays.asList("РЕДАКТИРОВАНИЕ КОНФЕРЕНЦИИ", "/conferences/conference?id=0"), + new ConferencesDashboardPage(), Arrays.asList("АКТУАЛЬНЫЕ КОНФЕРЕНЦИИ", "/conferences/dashboard") + ); + + @Autowired + private ApplicationProperties applicationProperties; + + @Test + public void testStartApplication() { + getContext().goTo(applicationProperties.getBaseUrl()); + Assertions + .assertThat(getContext().getTitle()) + .isEqualTo("NG-Tracker"); + } + + @Test + public void testCreateNewConference() { + Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 1); + + getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); + ConferencePage conferencePage = (ConferencePage) getContext().initPage(page.getKey()); + ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 0).getKey()); + + String newConferenceName = "test " + (new Date()).getTime(); + conferencePage.setName(newConferenceName); + conferencePage.clickSaveBut(); + + Assert.assertTrue(conferencesPage.getConferencesList() + .stream() + .anyMatch(webElement -> webElement.getText().equals(newConferenceName))); + } +} diff --git a/src/test/java/conference/ConferencePage.java b/src/test/java/conference/ConferencePage.java new file mode 100644 index 0000000..5f57008 --- /dev/null +++ b/src/test/java/conference/ConferencePage.java @@ -0,0 +1,19 @@ +package conference; + +import core.PageObject; +import org.openqa.selenium.By; + +public class ConferencePage extends PageObject { + + public String getSubTitle() { + return driver.findElement(By.tagName("h3")).getText(); + } + + public void setName(String name) { + driver.findElement(By.id("title")).sendKeys(name); + } + + public void clickSaveBut() { + driver.findElement(By.id("send-message-button")).click(); + } +} diff --git a/src/test/java/conference/ConferencesDashboardPage.java b/src/test/java/conference/ConferencesDashboardPage.java new file mode 100644 index 0000000..d358c4a --- /dev/null +++ b/src/test/java/conference/ConferencesDashboardPage.java @@ -0,0 +1,11 @@ +package conference; + +import core.PageObject; +import org.openqa.selenium.By; + +public class ConferencesDashboardPage extends PageObject { + + public String getSubTitle() { + return driver.findElement(By.tagName("h2")).getText(); + } +} diff --git a/src/test/java/conference/ConferencesPage.java b/src/test/java/conference/ConferencesPage.java new file mode 100644 index 0000000..0dc899d --- /dev/null +++ b/src/test/java/conference/ConferencesPage.java @@ -0,0 +1,19 @@ +package conference; + +import core.PageObject; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import java.util.List; + +public class ConferencesPage extends PageObject { + + public String getSubTitle() { + return driver.findElement(By.tagName("h3")).getText(); + } + + public List getConferencesList() { + return driver.findElements(By.cssSelector("span.h6.float-left.m-2")); + + } +} \ No newline at end of file From 1ad66d6fb17bcf14d12fc8ca7fa9218419ad1665 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 10 May 2019 15:54:12 +0400 Subject: [PATCH 02/17] #103 change name method test --- src/test/java/IndexConferenceTest.java | 21 +++++++++++++++++++ src/test/java/conference/ConferencePage.java | 4 ++++ src/test/java/conference/ConferencesPage.java | 3 +++ 3 files changed, 28 insertions(+) diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index 9adf2f5..b3a4118 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -56,4 +56,25 @@ public class IndexConferenceTest extends TestTemplate { .stream() .anyMatch(webElement -> webElement.getText().equals(newConferenceName))); } + + @Test + public void testChangeConferenceNameAndSave() { + 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 newConferenceName = "test " + (new Date()).getTime(); + conferencePage.clearName(); + conferencePage.setName(newConferenceName); + conferencePage.clickSaveBut(); + + Assert.assertTrue(conferencesPage.getConferencesList() + .stream() + .anyMatch(webElement -> webElement.getText().equals(newConferenceName))); + } + + } diff --git a/src/test/java/conference/ConferencePage.java b/src/test/java/conference/ConferencePage.java index 5f57008..48362e0 100644 --- a/src/test/java/conference/ConferencePage.java +++ b/src/test/java/conference/ConferencePage.java @@ -13,6 +13,10 @@ public class ConferencePage extends PageObject { driver.findElement(By.id("title")).sendKeys(name); } + public void clearName() { + driver.findElement(By.id("title")).clear(); + } + public void clickSaveBut() { driver.findElement(By.id("send-message-button")).click(); } diff --git a/src/test/java/conference/ConferencesPage.java b/src/test/java/conference/ConferencesPage.java index 0dc899d..b258420 100644 --- a/src/test/java/conference/ConferencesPage.java +++ b/src/test/java/conference/ConferencesPage.java @@ -14,6 +14,9 @@ public class ConferencesPage extends PageObject { public List getConferencesList() { return driver.findElements(By.cssSelector("span.h6.float-left.m-2")); + } + public void getConferenceFirst() { + driver.findElement(By.xpath("//*[@id=\"conferences\"]/div/div[2]/div[1]/div[1]/div/a")).click(); } } \ No newline at end of file From 253f4b4aad96dad266fb62fb1180bea11055e5dd Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 10 May 2019 17:03:47 +0400 Subject: [PATCH 03/17] #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 From 0cb7b05c2556f64b277c1d6903229ea0f38e72be Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 10 May 2019 17:21:36 +0400 Subject: [PATCH 04/17] #103 add check take part --- src/test/java/IndexConferenceTest.java | 21 ++++++++++++++++++++ src/test/java/conference/ConferencePage.java | 12 +++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index 7f8ee57..4fb72d4 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -106,4 +106,25 @@ public class IndexConferenceTest extends TestTemplate { && webElement.findElement(By.cssSelector("input[type=\"date\"]")).getAttribute("value").equals(dateValue); })); } + + @Test + public void testTakePartAndSave() { + 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 membersCount = conferencePage.getMemperCount(); + + conferencePage.clickTakePartBut(); + conferencePage.clickSaveBut(); + + getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); + + Assert.assertTrue(membersCount + 1 == conferencePage.getMemperCount() + && conferencePage.getTakePartButDisabledValue().equals("true")); + } } diff --git a/src/test/java/conference/ConferencePage.java b/src/test/java/conference/ConferencePage.java index 00d9585..9a448eb 100644 --- a/src/test/java/conference/ConferencePage.java +++ b/src/test/java/conference/ConferencePage.java @@ -51,4 +51,16 @@ public class ConferencePage extends PageObject { public void setDeadlineDate(String date, Integer i) { driver.findElement(By.id(String.format("deadlines%d.date", i))).sendKeys(date); } + + public void clickTakePartBut() { + driver.findElement(By.id("take-part")).click(); + } + + public String getTakePartButDisabledValue() { + return driver.findElement(By.id("take-part")).getAttribute("disabled"); + } + + public Integer getMemperCount() { + return driver.findElements(By.className("member")).size(); + } } \ No newline at end of file From 7b4318a3b528c93b0be5cbdcbc19cb4019485221 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 10 May 2019 17:40:24 +0400 Subject: [PATCH 05/17] #103 add delete deadline --- src/test/java/IndexConferenceTest.java | 20 ++++++++++++++++++++ src/test/java/conference/ConferencePage.java | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index 4fb72d4..8408029 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -127,4 +127,24 @@ public class IndexConferenceTest extends TestTemplate { Assert.assertTrue(membersCount + 1 == conferencePage.getMemperCount() && conferencePage.getTakePartButDisabledValue().equals("true")); } + + @Test + public void testDeleteDeadlineAndSave() { + 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(); + + conferencePage.clickDeleteDeadlineBut(); + conferencePage.clickSaveBut(); + + getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); + + Assert.assertTrue(deadlineCount - 1 == conferencePage.getDeadlineCount()); + } } diff --git a/src/test/java/conference/ConferencePage.java b/src/test/java/conference/ConferencePage.java index 9a448eb..d51e7b9 100644 --- a/src/test/java/conference/ConferencePage.java +++ b/src/test/java/conference/ConferencePage.java @@ -63,4 +63,8 @@ public class ConferencePage extends PageObject { public Integer getMemperCount() { return driver.findElements(By.className("member")).size(); } + + public void clickDeleteDeadlineBut() { + driver.findElement(By.xpath("//*[@id=\"deadlines\"]/div/input[4]")).click(); + } } \ No newline at end of file From d9a4224317c2ef5c5dae969003c6342a530d4500 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 10 May 2019 19:15:22 +0400 Subject: [PATCH 06/17] #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 From cad8682088abff0a54035edbcd0baaa2c5fe26b1 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 10 May 2019 20:07:55 +0400 Subject: [PATCH 07/17] #103 add adding article --- src/main/resources/public/css/conference.css | 6 +++++ src/test/java/IndexConferenceTest.java | 28 ++++++++++++++++++++ src/test/java/conference/ConferencePage.java | 4 +++ 3 files changed, 38 insertions(+) diff --git a/src/main/resources/public/css/conference.css b/src/main/resources/public/css/conference.css index 73a96ae..26ac40e 100644 --- a/src/main/resources/public/css/conference.css +++ b/src/main/resources/public/css/conference.css @@ -140,6 +140,7 @@ body { .paper-name { flex: 1; + overflow: hidden; } .paper-name:hover { @@ -156,6 +157,11 @@ body { float: left; } +.paper-name span:nth-child(2) { + max-width: 326px; + white-space: nowrap; +} + .icon { diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index 4c40d7d..a2e0124 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -176,4 +176,32 @@ public class IndexConferenceTest extends TestTemplate { .findElements(By.tagName("span")) .get(1).getText().equals(paperName))); } + + @Test + public void testAddArticle() { + 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.clickAddPaperBut(); + List webElements = conferencePage.getPapers(); + String paperName = webElements.get(webElements.size() - 1).findElement(By.tagName("a")).findElements(By.tagName("span")).get(1).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.tagName("a")) + .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 02fa0fc..1a4a1df 100644 --- a/src/test/java/conference/ConferencePage.java +++ b/src/test/java/conference/ConferencePage.java @@ -85,4 +85,8 @@ public class ConferencePage extends PageObject { webElement.click(); return webElement; } + + public void clickAddPaperBut() { + driver.findElement(By.id("add-paper")).click(); + } } \ No newline at end of file From 4e4e7ae1948ac8ccfe1c4c612358c6399f887b30 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 10 May 2019 20:54:43 +0400 Subject: [PATCH 08/17] #103 add paper transition --- src/main/resources/public/css/conference.css | 4 +++ src/test/java/IndexConferenceTest.java | 26 +++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/main/resources/public/css/conference.css b/src/main/resources/public/css/conference.css index 26ac40e..dc83057 100644 --- a/src/main/resources/public/css/conference.css +++ b/src/main/resources/public/css/conference.css @@ -162,6 +162,10 @@ body { white-space: nowrap; } +.dropdown-menu { + max-width: 445px; +} + .icon { diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index a2e0124..b3314ff 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -191,7 +191,7 @@ public class IndexConferenceTest extends TestTemplate { conferencePage.clickAddPaperBut(); List webElements = conferencePage.getPapers(); - String paperName = webElements.get(webElements.size() - 1).findElement(By.tagName("a")).findElements(By.tagName("span")).get(1).getText(); + String paperName = webElements.get(webElements.size() - 1).findElements(By.tagName("input")).get(1).getAttribute("value"); conferencePage.clickSaveBut(); getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); @@ -200,8 +200,26 @@ public class IndexConferenceTest extends TestTemplate { && conferencePage.getPapers() .stream() .anyMatch(webElement -> webElement - .findElement(By.tagName("a")) - .findElements(By.tagName("span")) - .get(1).getText().equals(paperName))); + .findElements(By.tagName("input")) + .get(1).getAttribute("value") + .equals(paperName))); + } + + @Test + public void testTransitionToTheArticle() { + 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(); + + WebElement paper = conferencePage.getPapers().get(0); + String paperName = paper.findElements(By.tagName("input")).get(1).getAttribute("value"); + paper.findElement(By.tagName("a")).click(); + + Assertions.assertThat(conferencePage.getName()) + .isEqualTo(paperName); } } From 46864069543d5c6f69572b68ab91c8e209069b1c Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 10 May 2019 21:15:49 +0400 Subject: [PATCH 09/17] #103 add undock article --- src/test/java/IndexConferenceTest.java | 38 ++++++++++++++++++++------ 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index b3314ff..84e51a2 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -159,17 +159,17 @@ public class IndexConferenceTest extends TestTemplate { conferencesPage.getConferenceFirst(); String conferenceId = conferencePage.getId(); - Integer paperCount = conferencePage.getPaperCount(); + Integer paperCount = conferencePage.getArticlesCount(); conferencePage.showAllowToAttachArticles(); - WebElement paper = conferencePage.selectPaper(); + WebElement paper = conferencePage.selectArticle(); 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() + Assert.assertTrue(paperCount + 1 == conferencePage.getArticlesCount() + && conferencePage.getArticles() .stream() .anyMatch(webElement -> webElement .findElement(By.className("paper-name")) @@ -187,17 +187,17 @@ public class IndexConferenceTest extends TestTemplate { conferencesPage.getConferenceFirst(); String conferenceId = conferencePage.getId(); - Integer paperCount = conferencePage.getPaperCount(); + Integer paperCount = conferencePage.getArticlesCount(); conferencePage.clickAddPaperBut(); - List webElements = conferencePage.getPapers(); + List webElements = conferencePage.getArticles(); String paperName = webElements.get(webElements.size() - 1).findElements(By.tagName("input")).get(1).getAttribute("value"); conferencePage.clickSaveBut(); getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); - Assert.assertTrue(paperCount + 1 == conferencePage.getPaperCount() - && conferencePage.getPapers() + Assert.assertTrue(paperCount + 1 == conferencePage.getArticlesCount() + && conferencePage.getArticles() .stream() .anyMatch(webElement -> webElement .findElements(By.tagName("input")) @@ -215,11 +215,31 @@ public class IndexConferenceTest extends TestTemplate { conferencesPage.getConferenceFirst(); - WebElement paper = conferencePage.getPapers().get(0); + WebElement paper = conferencePage.getArticles().get(0); String paperName = paper.findElements(By.tagName("input")).get(1).getAttribute("value"); paper.findElement(By.tagName("a")).click(); Assertions.assertThat(conferencePage.getName()) .isEqualTo(paperName); } + + @Test + public void testUndockArticle() { + 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.getArticlesCount(); + + conferencePage.clickUndockArticleBut(); + conferencePage.clickSaveBut(); + + getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); + + Assert.assertTrue(paperCount - 1 == conferencePage.getArticlesCount()); + } } From 6edcf8f5940fa3b3c0a0179d6910189412b8d230 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 10 May 2019 21:15:49 +0400 Subject: [PATCH 10/17] #103 add sort and filter test, fixed delete conference, if it has fk with event --- .../conference/service/ConferenceService.java | 1 + .../ulstu/timeline/service/EventService.java | 5 ++ src/test/java/IndexConferenceTest.java | 57 +++++++++++++++---- src/test/java/conference/ConferencePage.java | 15 +++-- src/test/java/conference/ConferencesPage.java | 10 ++++ 5 files changed, 71 insertions(+), 17 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index 38de435..e0662a2 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -127,6 +127,7 @@ public class ConferenceService { @Transactional public void delete(Integer conferenceId) { if (conferenceRepository.exists(conferenceId)) { + eventService.removeConferencesEvent(conferenceRepository.findOne(conferenceId)); conferenceRepository.delete(conferenceId); } } diff --git a/src/main/java/ru/ulstu/timeline/service/EventService.java b/src/main/java/ru/ulstu/timeline/service/EventService.java index b935f16..cd56a52 100644 --- a/src/main/java/ru/ulstu/timeline/service/EventService.java +++ b/src/main/java/ru/ulstu/timeline/service/EventService.java @@ -203,4 +203,9 @@ public class EventService { eventRepository.delete(eventRepository.findAllByGrant(grant)); createFromGrant(grant); } + + public void removeConferencesEvent(Conference conference) { + List eventList = eventRepository.findAllByConference(conference); + eventList.forEach(event -> eventRepository.delete(event.getId())); + } } diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index b3314ff..47af27f 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -159,22 +159,22 @@ public class IndexConferenceTest extends TestTemplate { conferencesPage.getConferenceFirst(); String conferenceId = conferencePage.getId(); - Integer paperCount = conferencePage.getPaperCount(); + Integer paperCount = conferencePage.getArticlesCount(); conferencePage.showAllowToAttachArticles(); - WebElement paper = conferencePage.selectPaper(); + WebElement paper = conferencePage.selectArticle(); 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() + Assert.assertTrue(paperCount + 1 == conferencePage.getArticlesCount() + && conferencePage.getArticles() .stream() .anyMatch(webElement -> webElement - .findElement(By.className("paper-name")) - .findElements(By.tagName("span")) - .get(1).getText().equals(paperName))); + .findElements(By.tagName("input")) + .get(1).getAttribute("value") + .equals(paperName))); } @Test @@ -187,17 +187,17 @@ public class IndexConferenceTest extends TestTemplate { conferencesPage.getConferenceFirst(); String conferenceId = conferencePage.getId(); - Integer paperCount = conferencePage.getPaperCount(); + Integer paperCount = conferencePage.getArticlesCount(); conferencePage.clickAddPaperBut(); - List webElements = conferencePage.getPapers(); + List webElements = conferencePage.getArticles(); String paperName = webElements.get(webElements.size() - 1).findElements(By.tagName("input")).get(1).getAttribute("value"); conferencePage.clickSaveBut(); getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); - Assert.assertTrue(paperCount + 1 == conferencePage.getPaperCount() - && conferencePage.getPapers() + Assert.assertTrue(paperCount + 1 == conferencePage.getArticlesCount() + && conferencePage.getArticles() .stream() .anyMatch(webElement -> webElement .findElements(By.tagName("input")) @@ -215,11 +215,44 @@ public class IndexConferenceTest extends TestTemplate { conferencesPage.getConferenceFirst(); - WebElement paper = conferencePage.getPapers().get(0); + WebElement paper = conferencePage.getArticles().get(0); String paperName = paper.findElements(By.tagName("input")).get(1).getAttribute("value"); paper.findElement(By.tagName("a")).click(); Assertions.assertThat(conferencePage.getName()) .isEqualTo(paperName); } + + @Test + public void testUndockArticle() { + 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.getArticlesCount(); + + conferencePage.clickUndockArticleBut(); + conferencePage.clickSaveBut(); + + getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); + + Assert.assertTrue(paperCount - 1 == conferencePage.getArticlesCount()); + } + + @Test + public void testSortAndFilterConferenceList() { + Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); + + getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); + ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey()); + + conferencesPage.selectMember(); + conferencesPage.selectYear(); + + Assert.assertEquals(1, conferencesPage.getConferencesList().size()); + } } diff --git a/src/test/java/conference/ConferencePage.java b/src/test/java/conference/ConferencePage.java index 1a4a1df..50e545e 100644 --- a/src/test/java/conference/ConferencePage.java +++ b/src/test/java/conference/ConferencePage.java @@ -72,21 +72,26 @@ public class ConferencePage extends PageObject { driver.findElement(By.cssSelector("button[data-id=\"paperIds\"]")).click(); } - public List getPapers() { + public void clickAddPaperBut() { + driver.findElement(By.id("add-paper")).click(); + } + + + public List getArticles() { return driver.findElements(By.className("paper")); } - public Integer getPaperCount() { + public Integer getArticlesCount() { return driver.findElements(By.className("paper")).size(); } - public WebElement selectPaper() { + public WebElement selectArticle() { 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; } - public void clickAddPaperBut() { - driver.findElement(By.id("add-paper")).click(); + public void clickUndockArticleBut() { + driver.findElement(By.name("removePaper")).click(); } } \ No newline at end of file diff --git a/src/test/java/conference/ConferencesPage.java b/src/test/java/conference/ConferencesPage.java index b258420..795ccf3 100644 --- a/src/test/java/conference/ConferencesPage.java +++ b/src/test/java/conference/ConferencesPage.java @@ -19,4 +19,14 @@ public class ConferencesPage extends PageObject { public void getConferenceFirst() { driver.findElement(By.xpath("//*[@id=\"conferences\"]/div/div[2]/div[1]/div[1]/div/a")).click(); } + + public void selectMember() { + driver.findElements(By.className("bootstrap-select")).get(0).findElement(By.className("btn")).click(); + driver.findElements(By.className("bootstrap-select")).get(0).findElements(By.className("dropdown-item")).get(1).click(); + } + + public void selectYear() { + driver.findElements(By.className("bootstrap-select")).get(1).findElement(By.className("btn")).click(); + driver.findElements(By.className("bootstrap-select")).get(1).findElements(By.className("dropdown-item")).get(1).click(); + } } \ No newline at end of file From b2e8a43ceec6f280324bea07c33d838cfd9c32ef Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Sat, 11 May 2019 00:51:57 +0400 Subject: [PATCH 11/17] #103 delete conf test --- src/test/java/IndexConferenceTest.java | 15 +++++++++++++++ src/test/java/conference/ConferencesPage.java | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index 47af27f..64b144d 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -255,4 +255,19 @@ public class IndexConferenceTest extends TestTemplate { Assert.assertEquals(1, conferencesPage.getConferencesList().size()); } + + @Test + public void testDeleteConf() throws InterruptedException { + Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); + + getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); + ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey()); + + Integer size = conferencesPage.getConferencesList().size(); + conferencesPage.deleteFirst(); + Thread.sleep(2000); + conferencesPage.clickConfirm(); + + Assert.assertEquals(size - 1, conferencesPage.getConferencesList().size()); + } } diff --git a/src/test/java/conference/ConferencesPage.java b/src/test/java/conference/ConferencesPage.java index 795ccf3..9cccf3f 100644 --- a/src/test/java/conference/ConferencesPage.java +++ b/src/test/java/conference/ConferencesPage.java @@ -29,4 +29,12 @@ public class ConferencesPage extends PageObject { driver.findElements(By.className("bootstrap-select")).get(1).findElement(By.className("btn")).click(); driver.findElements(By.className("bootstrap-select")).get(1).findElements(By.className("dropdown-item")).get(1).click(); } + + public void deleteFirst() { + driver.findElement(By.xpath("//*[@id=\"conferences\"]/div/div[2]/div[1]/div[1]/div/input[2]")).submit(); + } + + public void clickConfirm() { + driver.findElement(By.xpath("//*[@id=\"deleteConference\"]")).click(); + } } \ No newline at end of file From fe53c86136284413d153e6fc34700851ce98926e Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Sun, 12 May 2019 13:42:50 +0400 Subject: [PATCH 12/17] #103 fixed delete conf test --- src/test/java/IndexConferenceTest.java | 71 +++++++++---------- src/test/java/conference/ConferencesPage.java | 4 +- src/test/java/core/PageObject.java | 3 + 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index 64b144d..e893630 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -5,10 +5,11 @@ import conference.ConferencesDashboardPage; import conference.ConferencesPage; import core.PageObject; import core.TestTemplate; -import org.assertj.core.api.Assertions; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.springframework.beans.factory.annotation.Autowired; @@ -23,6 +24,7 @@ import java.util.List; import java.util.Map; @RunWith(SpringRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) @SpringBootTest(classes = NgTrackerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) public class IndexConferenceTest extends TestTemplate { private final Map> navigationHolder = ImmutableMap.of( @@ -35,15 +37,7 @@ public class IndexConferenceTest extends TestTemplate { private ApplicationProperties applicationProperties; @Test - public void testStartApplication() { - getContext().goTo(applicationProperties.getBaseUrl()); - Assertions - .assertThat(getContext().getTitle()) - .isEqualTo("NG-Tracker"); - } - - @Test - public void testCreateNewConference() { + public void testA_CreateNewConference() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 1); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -60,7 +54,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testChangeConferenceNameAndSave() { + public void testB_ChangeConferenceNameAndSave() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -79,7 +73,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testAddDeadlineAndSave() { + public void testC_AddDeadlineAndSave() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -109,7 +103,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testTakePartAndSave() { + public void testD_TakePartAndSave() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -130,7 +124,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testDeleteDeadlineAndSave() { + public void testE_DeleteDeadlineAndSave() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -146,11 +140,11 @@ public class IndexConferenceTest extends TestTemplate { getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); - Assert.assertTrue(deadlineCount - 1 == conferencePage.getDeadlineCount()); + Assert.assertEquals(deadlineCount - 1, (int) conferencePage.getDeadlineCount()); } @Test - public void testAttachArticle() { + public void testF_AttachArticle() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -178,7 +172,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testAddArticle() { + public void testG_AddArticle() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -205,26 +199,27 @@ public class IndexConferenceTest extends TestTemplate { .equals(paperName))); } - @Test - public void testTransitionToTheArticle() { - 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(); - - WebElement paper = conferencePage.getArticles().get(0); - String paperName = paper.findElements(By.tagName("input")).get(1).getAttribute("value"); - paper.findElement(By.tagName("a")).click(); - - Assertions.assertThat(conferencePage.getName()) - .isEqualTo(paperName); - } +// @Test +// @Order(8) +// public void testTransitionToTheArticle() { +// 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(); +// +// WebElement paper = conferencePage.getArticles().get(0); +// String paperName = paper.findElements(By.tagName("input")).get(1).getAttribute("value"); +// paper.findElement(By.tagName("a")).click(); +// +// Assertions.assertThat(conferencePage.getName()) +// .isEqualTo(paperName); +// } @Test - public void testUndockArticle() { + public void testH_UndockArticle() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -244,7 +239,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testSortAndFilterConferenceList() { + public void testI_SortAndFilterConferenceList() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -257,7 +252,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testDeleteConf() throws InterruptedException { + public void testJ_DeleteConf() throws InterruptedException { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -265,7 +260,7 @@ public class IndexConferenceTest extends TestTemplate { Integer size = conferencesPage.getConferencesList().size(); conferencesPage.deleteFirst(); - Thread.sleep(2000); + Thread.sleep(3000); conferencesPage.clickConfirm(); Assert.assertEquals(size - 1, conferencesPage.getConferencesList().size()); diff --git a/src/test/java/conference/ConferencesPage.java b/src/test/java/conference/ConferencesPage.java index 9cccf3f..5129f89 100644 --- a/src/test/java/conference/ConferencesPage.java +++ b/src/test/java/conference/ConferencesPage.java @@ -31,10 +31,10 @@ public class ConferencesPage extends PageObject { } public void deleteFirst() { - driver.findElement(By.xpath("//*[@id=\"conferences\"]/div/div[2]/div[1]/div[1]/div/input[2]")).submit(); + js.executeScript("$('input[data-confirm]').click();"); } public void clickConfirm() { - driver.findElement(By.xpath("//*[@id=\"deleteConference\"]")).click(); + driver.findElement(By.id("deleteConference")).click(); } } \ No newline at end of file diff --git a/src/test/java/core/PageObject.java b/src/test/java/core/PageObject.java index d1fae83..f3e5cb8 100644 --- a/src/test/java/core/PageObject.java +++ b/src/test/java/core/PageObject.java @@ -1,14 +1,17 @@ package core; +import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; public abstract class PageObject { protected WebDriver driver; + protected JavascriptExecutor js; public abstract String getSubTitle(); public PageObject setDriver(WebDriver driver) { this.driver = driver; + js = (JavascriptExecutor) driver; return this; } } From 70062992ae44493b6ec871a8a53ccd3aac23d29e Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Sun, 12 May 2019 13:45:17 +0400 Subject: [PATCH 13/17] #103 clear code --- src/test/java/IndexConferenceTest.java | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index e893630..7796502 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -199,25 +199,6 @@ public class IndexConferenceTest extends TestTemplate { .equals(paperName))); } -// @Test -// @Order(8) -// public void testTransitionToTheArticle() { -// 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(); -// -// WebElement paper = conferencePage.getArticles().get(0); -// String paperName = paper.findElements(By.tagName("input")).get(1).getAttribute("value"); -// paper.findElement(By.tagName("a")).click(); -// -// Assertions.assertThat(conferencePage.getName()) -// .isEqualTo(paperName); -// } - @Test public void testH_UndockArticle() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); From 5cbbb6c3190e2a28d793f8865722abef100475d4 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Sun, 12 May 2019 13:49:49 +0400 Subject: [PATCH 14/17] #103 fix code style --- src/test/java/IndexConferenceTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index 7796502..c38414a 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -37,7 +37,7 @@ public class IndexConferenceTest extends TestTemplate { private ApplicationProperties applicationProperties; @Test - public void testA_CreateNewConference() { + public void testACreateNewConference() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 1); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -54,7 +54,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testB_ChangeConferenceNameAndSave() { + public void testBChangeConferenceNameAndSave() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -73,7 +73,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testC_AddDeadlineAndSave() { + public void testCAddDeadlineAndSave() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -103,7 +103,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testD_TakePartAndSave() { + public void testDTakePartAndSave() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -124,7 +124,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testE_DeleteDeadlineAndSave() { + public void testEDeleteDeadlineAndSave() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -144,7 +144,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testF_AttachArticle() { + public void testFAttachArticle() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -172,7 +172,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testG_AddArticle() { + public void testGAddArticle() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -200,7 +200,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testH_UndockArticle() { + public void testHUndockArticle() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -216,7 +216,7 @@ public class IndexConferenceTest extends TestTemplate { getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); - Assert.assertTrue(paperCount - 1 == conferencePage.getArticlesCount()); + Assert.assertEquals(paperCount - 1, (int) conferencePage.getArticlesCount()); } @Test From 451e7e5d04728e85a627852b3340b2b313b8e804 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Sun, 12 May 2019 13:50:46 +0400 Subject: [PATCH 15/17] #103 fix code style --- src/test/java/IndexConferenceTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index c38414a..7dbd39b 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -220,7 +220,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testI_SortAndFilterConferenceList() { + public void testISortAndFilterConferenceList() { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); @@ -233,7 +233,7 @@ public class IndexConferenceTest extends TestTemplate { } @Test - public void testJ_DeleteConf() throws InterruptedException { + public void testJDeleteConf() throws InterruptedException { Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); From 1f8722e3ff6036da36a57f328ad2a7a722e92650 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Mon, 13 May 2019 20:13:53 +0400 Subject: [PATCH 16/17] #103 code refactoring --- src/test/java/IndexConferenceTest.java | 45 ++++++------------- src/test/java/conference/ConferencePage.java | 23 +++++++++- src/test/java/conference/ConferencesPage.java | 9 +++- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index 7dbd39b..269561f 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -48,9 +48,7 @@ public class IndexConferenceTest extends TestTemplate { conferencePage.setName(newConferenceName); conferencePage.clickSaveBut(); - Assert.assertTrue(conferencesPage.getConferencesList() - .stream() - .anyMatch(webElement -> webElement.getText().equals(newConferenceName))); + Assert.assertTrue(conferencesPage.checkNameInList(newConferenceName)); } @Test @@ -61,15 +59,13 @@ public class IndexConferenceTest extends TestTemplate { ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey()); ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey()); - conferencesPage.getConferenceFirst(); + conferencesPage.getFirstConference(); String newConferenceName = "test " + (new Date()).getTime(); conferencePage.clearName(); conferencePage.setName(newConferenceName); conferencePage.clickSaveBut(); - Assert.assertTrue(conferencesPage.getConferencesList() - .stream() - .anyMatch(webElement -> webElement.getText().equals(newConferenceName))); + Assert.assertTrue(conferencesPage.checkNameInList(newConferenceName)); } @Test @@ -80,7 +76,7 @@ public class IndexConferenceTest extends TestTemplate { ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey()); ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey()); - conferencesPage.getConferenceFirst(); + conferencesPage.getFirstConference(); String conferenceId = conferencePage.getId(); Integer deadlineCount = conferencePage.getDeadlineCount(); @@ -94,12 +90,7 @@ public class IndexConferenceTest extends TestTemplate { 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); - })); + Assert.assertTrue(conferencePage.checkDeadline(description, dateValue)); } @Test @@ -110,7 +101,7 @@ public class IndexConferenceTest extends TestTemplate { ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey()); ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey()); - conferencesPage.getConferenceFirst(); + conferencesPage.getFirstConference(); String conferenceId = conferencePage.getId(); Integer membersCount = conferencePage.getMemberCount(); @@ -120,7 +111,7 @@ public class IndexConferenceTest extends TestTemplate { getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); Assert.assertTrue(membersCount + 1 == conferencePage.getMemberCount() - && conferencePage.getTakePartButDisabledValue().equals("true")); + && conferencePage.isTakePartButDisabledValueTrue()); } @Test @@ -131,7 +122,7 @@ public class IndexConferenceTest extends TestTemplate { ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey()); ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey()); - conferencesPage.getConferenceFirst(); + conferencesPage.getFirstConference(); String conferenceId = conferencePage.getId(); Integer deadlineCount = conferencePage.getDeadlineCount(); @@ -151,7 +142,7 @@ public class IndexConferenceTest extends TestTemplate { ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey()); ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey()); - conferencesPage.getConferenceFirst(); + conferencesPage.getFirstConference(); String conferenceId = conferencePage.getId(); Integer paperCount = conferencePage.getArticlesCount(); @@ -163,12 +154,7 @@ public class IndexConferenceTest extends TestTemplate { getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); Assert.assertTrue(paperCount + 1 == conferencePage.getArticlesCount() - && conferencePage.getArticles() - .stream() - .anyMatch(webElement -> webElement - .findElements(By.tagName("input")) - .get(1).getAttribute("value") - .equals(paperName))); + && conferencePage.checkArticle(paperName)); } @Test @@ -179,7 +165,7 @@ public class IndexConferenceTest extends TestTemplate { ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey()); ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey()); - conferencesPage.getConferenceFirst(); + conferencesPage.getFirstConference(); String conferenceId = conferencePage.getId(); Integer paperCount = conferencePage.getArticlesCount(); @@ -191,12 +177,7 @@ public class IndexConferenceTest extends TestTemplate { getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId)); Assert.assertTrue(paperCount + 1 == conferencePage.getArticlesCount() - && conferencePage.getArticles() - .stream() - .anyMatch(webElement -> webElement - .findElements(By.tagName("input")) - .get(1).getAttribute("value") - .equals(paperName))); + && conferencePage.checkArticle(paperName)); } @Test @@ -207,7 +188,7 @@ public class IndexConferenceTest extends TestTemplate { ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey()); ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey()); - conferencesPage.getConferenceFirst(); + conferencesPage.getFirstConference(); String conferenceId = conferencePage.getId(); Integer paperCount = conferencePage.getArticlesCount(); diff --git a/src/test/java/conference/ConferencePage.java b/src/test/java/conference/ConferencePage.java index 50e545e..ef0d941 100644 --- a/src/test/java/conference/ConferencePage.java +++ b/src/test/java/conference/ConferencePage.java @@ -56,8 +56,8 @@ public class ConferencePage extends PageObject { driver.findElement(By.id("take-part")).click(); } - public String getTakePartButDisabledValue() { - return driver.findElement(By.id("take-part")).getAttribute("disabled"); + public Boolean isTakePartButDisabledValueTrue() { + return driver.findElement(By.id("take-part")).getAttribute("disabled").equals("true"); } public Integer getMemberCount() { @@ -94,4 +94,23 @@ public class ConferencePage extends PageObject { public void clickUndockArticleBut() { driver.findElement(By.name("removePaper")).click(); } + + public boolean checkDeadline(String description, String dateValue) { + return 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); + }); + } + + public boolean checkArticle(String paperName) { + return getArticles() + .stream() + .anyMatch(webElement -> webElement + .findElements(By.tagName("input")) + .get(1).getAttribute("value") + .equals(paperName)); + } + } \ No newline at end of file diff --git a/src/test/java/conference/ConferencesPage.java b/src/test/java/conference/ConferencesPage.java index 5129f89..c11429f 100644 --- a/src/test/java/conference/ConferencesPage.java +++ b/src/test/java/conference/ConferencesPage.java @@ -16,7 +16,7 @@ public class ConferencesPage extends PageObject { return driver.findElements(By.cssSelector("span.h6.float-left.m-2")); } - public void getConferenceFirst() { + public void getFirstConference() { driver.findElement(By.xpath("//*[@id=\"conferences\"]/div/div[2]/div[1]/div[1]/div/a")).click(); } @@ -37,4 +37,11 @@ public class ConferencesPage extends PageObject { public void clickConfirm() { driver.findElement(By.id("deleteConference")).click(); } + + + public boolean checkNameInList(String newConferenceName) { + return getConferencesList() + .stream() + .anyMatch(webElement -> webElement.getText().equals(newConferenceName)); + } } \ No newline at end of file From ab59cb524e4e3eecbbdd4bb56f475fe065445da5 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Mon, 13 May 2019 20:26:13 +0400 Subject: [PATCH 17/17] #103 fix code style --- src/main/resources/public/js/conference.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/public/js/conference.js b/src/main/resources/public/js/conference.js index 18a8c67..8273557 100644 --- a/src/main/resources/public/js/conference.js +++ b/src/main/resources/public/js/conference.js @@ -25,4 +25,5 @@ $(document).ready(function () { $('#dataConfirmModal').modal({show:true}); return false; }); + });