#103 add attach article

This commit is contained in:
Nightblade73 2019-05-10 19:15:22 +04:00
parent 7b4318a3b5
commit d9a4224317
2 changed files with 50 additions and 3 deletions

View File

@ -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<PageObject, List<String>> 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)));
}
}

View File

@ -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<WebElement> 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;
}
}