Commit 13a18d92 authored by Vadim Nesmashnov's avatar Vadim Nesmashnov

RIHAKB-860, RIHA haldajana soovin, et RIHA manuaalsed funktsionaalsuse testid...

RIHAKB-860, RIHA haldajana soovin, et RIHA manuaalsed funktsionaalsuse testid oleks võimalikult suures ulatuses automatiseeritud
parent d6c445bd
......@@ -5,6 +5,8 @@ import java.util.Map;
public class ScenarioContext {
public static final String APP_URL_KEY = "appUrl";
public static final String SEARCH_TEXT_KEY = "searchText";
public static final String LAST_INFOSYSTEM_NUMBER = "lastInfosystemNumber";
public static final String DEFAULT_APP_URL = "https://riha-browser-ik.ci.kit";
private final Map<String, String> context = new HashMap<>();
......
......@@ -19,4 +19,8 @@ public class BasePage {
public String getCurrentUrl() {
return driver.getCurrentUrl();
}
public ScenarioContext getScenarioContext() {
return scenarioContext;
}
}
package ee.ria.riha.pages;
import ee.ria.riha.context.ScenarioContext;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
......@@ -11,16 +12,25 @@ import static ee.ria.riha.Timeouts.DISPLAY_ELEMENT_TIMEOUT;
public class InfosystemPage extends BasePage {
@FindBy(xpath = "//div[@id='uldkirjeldus']/app-producer-details-general/section/div[2]/div[2]/p")
private WebElement purposeP;
@FindBy(xpath = "//div[@id='uldkirjeldus']/app-producer-details-general/section/div[2]/div[3]/div")
private WebElement topicsDiv;
public InfosystemPage() {
public InfosystemPage(ScenarioContext scenarioContext) {
super(scenarioContext);
PageFactory.initElements(driver, this);
}
public String getAssociatedTopicsList() {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, topicsDiv, "topicsDiv");
return topicsDiv.findElements(By.tagName("button")).stream().map(button -> button.getText()).collect(Collectors.joining(","));
return topicsDiv.findElements(By.tagName("button")).stream().map(WebElement::getText).collect(Collectors.joining(","));
}
public String getPurposeText() {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, purposeP, "purposeP");
return purposeP.getText();
}
public void clickOnTopic(String topic) {
......
package ee.ria.riha.pages;
import ee.ria.riha.context.ScenarioContext;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
......@@ -29,7 +30,8 @@ public class InfosystemsPage extends BasePage {
@FindBy(id = "info-systems-table")
private WebElement infosystemsTable;
public InfosystemsPage() {
public InfosystemsPage(ScenarioContext scenarioContext) {
super(scenarioContext);
PageFactory.initElements(driver, this);
}
......@@ -87,7 +89,7 @@ public class InfosystemsPage extends BasePage {
waitForLoading();
}
public void waitForLoading() {
private void waitForLoading() {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, infosystemsTable, "info-systems-table");
wait.sleep(TABLE_SORT_TIMEOUT);
}
......
package ee.ria.riha.pages;
import ee.ria.riha.context.ScenarioContext;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
......@@ -17,7 +18,8 @@ public class LoginPage extends BasePage {
@FindBy(css = "tr:nth-child(3) .c-btn")
private WebElement jatkanButton;
public LoginPage() {
public LoginPage(ScenarioContext scenarioContext) {
super(scenarioContext);
PageFactory.initElements(driver, this);
}
......
package ee.ria.riha.pages;
import ee.ria.riha.context.ScenarioContext;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
......@@ -12,11 +13,16 @@ import java.util.stream.Collectors;
import static ee.ria.riha.Timeouts.DISPLAY_ELEMENT_TIMEOUT;
import static ee.ria.riha.Timeouts.TABLE_SORT_TIMEOUT;
import static ee.ria.riha.context.ScenarioContext.LAST_INFOSYSTEM_NUMBER;
import static ee.ria.riha.context.ScenarioContext.SEARCH_TEXT_KEY;
public class MyInfosystemsPage extends BasePage {
@FindBy(xpath = "//main[@id='content']/app-producer-list/section/div[2]/a[4]")
private WebElement detailedSearchLink;
@FindBy(id = "search-text-input")
private WebElement searchTextInput;
@FindBy(id = "topics-input")
private WebElement topicsInput;
......@@ -38,7 +44,11 @@ public class MyInfosystemsPage extends BasePage {
@FindBy(id = "infosystems-table")
private WebElement infosystemsTable;
public MyInfosystemsPage() {
@FindBy(xpath = "//table[@id='infosystems-table']/thead/th/app-sort-button/button")
private WebElement sortByShortNameButton;
public MyInfosystemsPage(ScenarioContext scenarioContext) {
super(scenarioContext);
PageFactory.initElements(driver, this);
}
......@@ -73,14 +83,40 @@ public class MyInfosystemsPage extends BasePage {
createNewLink.click();
}
public void enterNameShortNameAndPurpose(String name, String shortName, String purpose) {
nameInput.sendKeys(name);
shortNameInput.sendKeys(shortName);
public void enterNameShortNameAndPurpose(String namePrefix, String shortNamePrefix, String purpose) {
String lastCreatedInfosystemNumber = scenarioContext.getFromContext(LAST_INFOSYSTEM_NUMBER);
int i = Integer.parseInt(lastCreatedInfosystemNumber);
i++;
nameInput.sendKeys(namePrefix + " " + i);
shortNameInput.sendKeys(shortNamePrefix + "-" + i);
purposeInput.sendKeys(purpose);
submitButton.click();
}
public void waitForLoading() {
public void enterSearchText(String text) {
waitForLoading();
scenarioContext.saveToContext(SEARCH_TEXT_KEY, text);
searchTextInput.sendKeys(text);
searchTextInput.sendKeys(Keys.RETURN);
waitForLoading();
}
public void sortByShortNameDesc() {
sortByShortNameButton.click(); //asc
waitForLoading();
sortByShortNameButton.click(); //desc
waitForLoading();
}
public void saveFirstFoundInfosystemShortNameToScenarioContext() {
WebElement firstRow = infosystemsTable.findElement(By.xpath("//tr[1]"));
String shortName = firstRow.findElement(By.xpath("//td[1]")).findElement(By.tagName("a")).getText();
scenarioContext.saveToContext(LAST_INFOSYSTEM_NUMBER, shortName.substring(scenarioContext.getFromContext(SEARCH_TEXT_KEY).length() + 1));
}
private void waitForLoading() {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, infosystemsTable, "infosystems-table");
wait.sleep(TABLE_SORT_TIMEOUT);
}
......
package ee.ria.riha.myinfosystemspage;
package ee.ria.riha.infosystemmanagement;
import ee.ria.riha.driver.Setup;
import ee.ria.riha.pages.MyInfosystemsPage;
......@@ -7,10 +7,10 @@ import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.junit.Assert;
public class MyInfosystemsPageSteps {
public class InfosystemManagementSteps {
private MyInfosystemsPage myInfosystemsPage;
public MyInfosystemsPageSteps() {
public InfosystemManagementSteps() {
myInfosystemsPage = Setup.pageFactory.getPage(MyInfosystemsPage.class);
}
......@@ -29,9 +29,16 @@ public class MyInfosystemsPageSteps {
myInfosystemsPage.goToCreateNewInfosystemPage();
}
@And("MyInfosystemsPage: user enters name as {string} short name as {string} and purpose as {string}")
public void userEntersNameShortNameAndPurpose(String name, String shortName, String purpose) {
myInfosystemsPage.enterNameShortNameAndPurpose(name, shortName, purpose);
@And("MyInfosystemsPage: user enters name as {string} short name as {string} increasing last number and purpose as {string}")
public void userEntersNameShortNameAndPurpose(String namePrefix, String shortNamePrefix, String purpose) {
myInfosystemsPage.enterNameShortNameAndPurpose(namePrefix, shortNamePrefix, purpose);
}
@And("MyInfosystemsPage: user knows the number of last created infosystem with prefix {string}")
public void userKnowsTheNameOfLastCreatedInfosystem(String namePrefix) {
myInfosystemsPage.enterSearchText(namePrefix);
myInfosystemsPage.sortByShortNameDesc();
myInfosystemsPage.saveFirstFoundInfosystemShortNameToScenarioContext();
}
@When("MyInfosystemsPage: user clicks on {string} infosystem link")
......
package ee.ria.riha.myinfosystemspage;
package ee.ria.riha.infosystemmanagement;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(features = {"src/test/resources/ee/ria/riha/MyInfosystems.feature"},
@CucumberOptions(features = {"src/test/resources/ee/ria/riha/InfosystemManagement.feature"},
strict = false, plugin = {"pretty",
"json:target/cucumber_json_reports/my-infosystems-page.json",
"html:target/my-infosystems-page-html"},
"json:target/cucumber_json_reports/infosystem-management-page.json",
"html:target/infosystem-management-page-html"},
glue = {"ee.ria.riha"})
public class MyInfosystemsPageTest {
public class InfosystemManagementTest {
}
......@@ -22,4 +22,9 @@ public class InfosystemPageSteps {
public void topicIsPresentInAssociatedTopicsList(String topic) {
Assert.assertTrue("Associated topic list doen't contain topic " + topic, infosystemPage.getAssociatedTopicsList().contains(topic.toUpperCase()));
}
@Then("InfosytemPage: infosystem creation purpose is {string}")
public void infosystemCreationPurposeIs(String purpose) {
Assert.assertTrue("Infosystem creation purpose is not " + purpose, purpose.equalsIgnoreCase(infosystemPage.getPurposeText()));
}
}
Feature: My organization infosystems page functionality
Background:
Given User is logged in to "/" as "60001019906" using tel. number "00000766"
Scenario: User can create new infosystem (RIHAKB-340)
Given HomePage: user opens 'my organization infosystems' page
And MyInfosystemsPage: user knows the number of last created infosystem with prefix "autotest"
And MyInfosystemsPage: user clicks 'Lisa uus'
And MyInfosystemsPage: user enters name as "RIHA autotest number" short name as "autotest" increasing last number and purpose as "Testida RIHA funktsionaalsust"
Then InfosytemPage: infosystem creation purpose is "Testida RIHA funktsionaalsust"
\ No newline at end of file
Feature: My organization infosystems page functionality
Background:
Given User is logged in to "/" as "60001019906" using tel. number "00000766"
# Scenario: User can create new infosystem (RIHAKB-340)
# Given User opens 'my organization infosystems page'
# And user clicks 'Lisa uus'
# And user enters name as "" short name as "" and purpose as ""
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment