#103 add tests for papers
This commit is contained in:
parent
3e9bbb3584
commit
47131f1fb7
@ -81,7 +81,6 @@ public class IndexGrantTest extends TestTemplate {
|
||||
@Test
|
||||
public void deleteGrant() throws InterruptedException {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
GrantsPage grantsPage = (GrantsPage) getContext().initPage(page.getKey());
|
||||
|
||||
@ -89,4 +88,33 @@ public class IndexGrantTest extends TestTemplate {
|
||||
grantsPage.deleteFirst();
|
||||
Assert.assertEquals(size - 1, grantsPage.getGrantsList().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void attachPaper() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
GrantsPage grantsPage = (GrantsPage) getContext().initPage(page.getKey());
|
||||
GrantPage grantPage = (GrantPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
|
||||
grantsPage.getFirstGrant();
|
||||
Integer countPapers = grantPage.getAttachedPapers().size();
|
||||
|
||||
Assert.assertEquals(countPapers + 1, grantPage.attachPaper().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deletePaper() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
GrantsPage grantsPage = (GrantsPage) getContext().initPage(page.getKey());
|
||||
GrantPage grantPage = (GrantPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
|
||||
grantsPage.getFirstGrant();
|
||||
Integer oldCountPapers = grantPage.getAttachedPapers().size();
|
||||
if (oldCountPapers == 0) {
|
||||
oldCountPapers = grantPage.attachPaper().size();
|
||||
}
|
||||
|
||||
Assert.assertEquals(oldCountPapers - 1, grantPage.deletePaper().size());
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.ui.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GrantPage extends PageObject {
|
||||
@Override
|
||||
public String getSubTitle() {
|
||||
@ -45,4 +47,40 @@ public class GrantPage extends PageObject {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<WebElement> getAttachedPapers() {
|
||||
try {
|
||||
return driver.findElement(By.className("div-selected-papers")).findElements(By.tagName("div"));
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<WebElement> attachPaper() {
|
||||
WebElement selectPapers = driver.findElement(By.id("allPapers"));
|
||||
Select select = new Select(selectPapers);
|
||||
List<WebElement> selectedOptions = select.getAllSelectedOptions();
|
||||
List<WebElement> allOptions = select.getOptions();
|
||||
if (selectedOptions.size() >= allOptions.size()) {
|
||||
for (int i = 0; i < allOptions.size(); i++) {
|
||||
if (!allOptions.get(i).equals(selectedOptions.get(i))) {
|
||||
select.selectByVisibleText(allOptions.get(i).getText());
|
||||
selectedOptions.add(allOptions.get(i));
|
||||
return selectedOptions;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
select.selectByVisibleText(allOptions.get(0).getText());
|
||||
selectedOptions.add(allOptions.get(0));
|
||||
return selectedOptions;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<WebElement> deletePaper() {
|
||||
WebElement selectPapers = driver.findElement(By.id("allPapers"));
|
||||
Select select = new Select(selectPapers);
|
||||
select.deselectByVisibleText(select.getFirstSelectedOption().getText());
|
||||
return select.getAllSelectedOptions();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user