#103 code refactoring
This commit is contained in:
parent
451e7e5d04
commit
1f8722e3ff
@ -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();
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user