Commit ab73bb2c 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 9645e818
Pipeline #162 failed with stages
package ee.ria.riha.page;
package ee.ria.riha.pages;
import ee.ria.riha.driver.Setup;
import ee.ria.riha.driver.Wait;
......
package ee.ria.riha.homepage;
package ee.ria.riha.pages;
import ee.ria.riha.page.BasePage;
import ee.ria.riha.pages.BasePage;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
......@@ -15,34 +14,51 @@ public class HomePage extends BasePage {
@FindBy(css = ".btn > span:nth-child(1)")
private WebElement loginButton;
@FindBy(css = ".card:nth-child(2) .btn")
private WebElement goToMyInfosystemsPageButton;
@FindBy(tagName = "ngb-modal-window")
private WebElement modalContainer;
HomePage() {
public HomePage() {
PageFactory.initElements(driver, this);
}
void goToHomePage(String url) {
public void goToHomePage(String url) {
driver.get(url);
wait.forLoading(5);
}
void checkLogoDisplay() {
public void checkLogoDisplay() {
wait.forElementToBeDisplayed(5, this.logo, "Logo");
}
String getTitle() {
public String getTitle() {
return driver.getTitle();
}
String getLoggedInUsersName() {
wait.forPresenceOfElements(25, By.tagName("ngb-modal-window"), "modal");
// this.modalContainer.findElement(By.cssSelector("tr:nth-child(1) > td")).click();
return this.driver.findElement(By.cssSelector("a:nth-child(2)")).getText();
public String getLoggedInUsersName() {
return this.driver.findElement(By.cssSelector(".right a")).getText();
}
public void selectSecondOrganization() {
this.wait.forPresenceOfElements(25, By.tagName("ngb-modal-window"), "modal");
this.modalContainer.findElement(By.cssSelector("tr:nth-child(2) > td")).click();
}
public void selectOrganization(String organization) {
this.driver.findElement(By.cssSelector(".right a")).click();
this.wait.forPresenceOfElements(2, By.tagName("ngb-modal-window"), "modal");
this.modalContainer.findElement(By.xpath("//td[contains(.,'" + organization +"')]")).click();
}
void goToLoginPage() {
public void goToLoginPage() {
this.loginButton.click();
wait.forLoading(5);
}
public void goToMyInfosystemsPage() {
this.goToMyInfosystemsPageButton.click();
wait.forLoading(5);
}
}
\ No newline at end of file
package ee.ria.riha.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import java.util.stream.Collectors;
public class InfosystemPage extends BasePage {
@FindBy(xpath = "//div[@id='uldkirjeldus']/app-producer-details-general/section/div[2]/div[3]/div")
private WebElement topicsDiv;
public InfosystemPage() {
PageFactory.initElements(driver, this);
}
public String getAssociatedTopicsList() {
wait.forElementToBeDisplayed(5, topicsDiv, "topicsDiv");
return topicsDiv.findElements(By.tagName("button")).stream().map(button -> button.getText()).collect(Collectors.joining(","));
}
public void clickOnTopic(String topic) {
topicsDiv.findElements(By.tagName("button")).stream().filter(button -> button.getText().equalsIgnoreCase(topic)).findFirst().get().click();
}
}
package ee.ria.riha.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class InfosystemsPage extends BasePage {
@FindBy(id = "topics-input")
private WebElement topicsInput;
@FindBy(id = "info-systems-table")
private WebElement infosystemsTable;
public InfosystemsPage() {
PageFactory.initElements(driver, this);
}
public List<String> getFoundInfosystemsTopics() throws InterruptedException {
this.wait.forElementToBeDisplayed(10, infosystemsTable, "info-systems-table");
Thread.sleep(2000);
List<String> topics = new ArrayList<>();
List<WebElement> tableRows = infosystemsTable.findElements(By.tagName("tr"));
tableRows.forEach(row -> {
if(row.findElements(By.className("topics")).size() > 0) {
topics.add(row.findElement(By.className("topics")).findElements(By.tagName("button")).stream().map(WebElement::getText).collect(Collectors.joining(",")));
}
});
return topics;
}
public String getTopicInputText() {
return topicsInput.getAttribute("value");
}
}
package ee.ria.riha.loginpage;
package ee.ria.riha.pages;
import ee.ria.riha.page.BasePage;
import ee.ria.riha.pages.BasePage;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
......@@ -18,15 +18,15 @@ public class LoginPage extends BasePage {
@FindBy(css = "tr:nth-child(3) .c-btn")
private WebElement jatkanButton;
LoginPage() {
public LoginPage() {
PageFactory.initElements(driver, this);
}
void selectsMobiilIdTab() {
public void selectMobiilIdTab() {
this.mobiilIdTab.click();
}
void enterIsikukoodAndTelefoninumber(String personalCode, String phoneNumber) {
public void enterIsikukoodAndTelefoninumber(String personalCode, String phoneNumber) {
this.isikukoodInput.sendKeys(personalCode);
this.telefoninumberInput.sendKeys(phoneNumber);
this.jatkanButton.click();
......
package ee.ria.riha.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class MyInfosystemsPage extends BasePage {
@FindBy(xpath = "//main[@id='content']/app-producer-list/section/div[2]/a[4]")
private WebElement detailedSearchLink;
@FindBy(id = "topics-input")
private WebElement topicsInput;
// @FindBy(id = "name-input")
// private WebElement nameInput;
//
// @FindBy(id = "short-name-input")
// private WebElement shortNameInput;
//
// @FindBy(id = "purpose-textarea")
// private WebElement purposeInput;
//
// @FindBy(css = ".table-responsive > .btn")
// private WebElement createNewLink;
//
// @FindBy(xpath = "//button[@type='submit']")
// private WebElement submitButton;
@FindBy(id = "infosystems-table")
private WebElement infosystemsTable;
public MyInfosystemsPage() {
PageFactory.initElements(driver, this);
}
public void openDetailedSearchForm() {
this.detailedSearchLink.click();
}
public void searchByTopic(String topic) throws Exception {
this.topicsInput.sendKeys(topic);
this.topicsInput.sendKeys(Keys.RETURN);
this.wait.forElementToBeDisplayed(10, infosystemsTable, "infosystems-table");
Thread.sleep(2000);
}
public List<String> getFoundInfosystemsTopics() {
List<String> topics = new ArrayList<>();
List<WebElement> tableRows = infosystemsTable.findElements(By.tagName("tr"));
tableRows.forEach(row -> {
topics.add(row.findElement(By.className("topics")).findElements(By.tagName("button")).stream().map(WebElement::getText).collect(Collectors.joining(",")));
});
return topics;
}
public void goToInfosystemPage(String infosystem) {
driver.findElement(By.linkText(infosystem)).click();
}
// public void goToCreateNewInfosystemPage() {
// this.wait.forElementToBeDisplayed(15, createNewLink, "createNewLink");
// this.createNewLink.click();
// }
//
// public void enterNameSHortNameAndPurpose(String name, String shortName, String purpose) {
// this.nameInput.sendKeys(name);
// this.shortNameInput.sendKeys(shortName);
// this.purposeInput.sendKeys(purpose);
// this.submitButton.click();
// }
}
package ee.ria.riha;
import ee.ria.riha.pages.HomePage;
import ee.ria.riha.pages.LoginPage;
import io.cucumber.java.en.Given;
public class BackgroundSteps {
private HomePage homePage;
private LoginPage loginPage;
public BackgroundSteps() {
this.loginPage = new LoginPage();
this.homePage = new HomePage();
}
@Given("^User is logged in to \"([^\"]*)\" as \"([^\"]*)\" using tel. number \"([^\"]*)\"$")
public void userIsLoggedInAsTestUser(String url, String personalCode, String phoneNumber) {
this.homePage.goToHomePage(url);
this.homePage.goToLoginPage();
this.loginPage.selectMobiilIdTab();
this.loginPage.enterIsikukoodAndTelefoninumber(personalCode, phoneNumber);
this.homePage.selectSecondOrganization();
}
}
package ee.ria.riha.homepage;
import ee.ria.riha.pages.HomePage;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
......@@ -13,8 +14,18 @@ public class HomePageSteps {
}
@Given("^A user navigates to HomePage \"([^\"]*)\"$")
public void aUserNavigatesToHomePage(String country) {
this.homePage.goToHomePage(country);
public void aUserNavigatesToHomePage(String url) {
this.homePage.goToHomePage(url);
}
@Given("^User selects organization \"([^\"]*)\"$")
public void userSelectsOrganization(String organization) {
this.homePage.selectOrganization(organization);
}
@Given("^User opens 'my organization infosystems page'$")
public void userOpensMyInfosystemsPage() {
this.homePage.goToMyInfosystemsPage();
}
@And("^user clicks on login button$")
......@@ -33,7 +44,13 @@ public class HomePageSteps {
}
@Then("^home page is opened showing logged in user's name \"([^\"]*)\"$")
public void userClicksOnLoginButton(String name) {
Assert.assertTrue("Displayed logged in user's name is " + this.homePage.getLoggedInUsersName() + " instead of " + name, name.equals(this.homePage.getLoggedInUsersName()));
public void homePageIsOpenedShowingLoggedInUsersName(String name) {
this.homePage.selectSecondOrganization();
Assert.assertTrue("Displayed logged in user's name is " + this.homePage.getLoggedInUsersName() + " instead of " + name, this.homePage.getLoggedInUsersName().contains(name));
}
@Then("^Organization name \"([^\"]*)\" is shown next to user's name$")
public void organizationNameIsShownNextToUsersName(String organizationName) {
Assert.assertTrue("Organization name " + organizationName + " is not shown", this.homePage.getLoggedInUsersName().contains(organizationName));
}
}
......@@ -5,11 +5,10 @@ import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(features = {"src/test/resources/ee/ria/riha/Home_page.feature"},
@CucumberOptions(features = {"src/test/resources/ee/ria/riha/HomePage.feature"},
strict = false, plugin = {"pretty",
"json:target/cucumber_json_reports/home-page.json",
"html:target/home-page-html"},
glue = {"ee.ria.riha.driver",
"ee.ria.riha.homepage"})
glue = {"ee.ria.riha"})
public class HomePageTest {
}
package ee.ria.riha.infosystempage;
import ee.ria.riha.pages.InfosystemPage;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.junit.Assert;
public class InfosystemPageSteps {
private InfosystemPage infosystemPage;
public InfosystemPageSteps() {
this.infosystemPage = new InfosystemPage();
}
@When("^user clicks on \"([^\"]*)\" topic$")
public void userClicksOnTopic(String topic) {
this.infosystemPage.clickOnTopic(topic);
}
@Then("^\"([^\"]*)\" topic is present in associated topics list$")
public void topicIsPresentInAssociatedTopicsList(String topic) {
Assert.assertTrue("Associated topic list doen't contain topic " + topic, this.infosystemPage.getAssociatedTopicsList().contains(topic.toUpperCase()));
}
}
package ee.ria.riha.infosystemspage;
import ee.ria.riha.pages.InfosystemsPage;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Then;
import org.junit.Assert;
public class InfosystemsPageSteps {
private InfosystemsPage infosystemsPage;
public InfosystemsPageSteps() {
this.infosystemsPage = new InfosystemsPage();
}
@And("^topic input has \"([^\"]*)\" text$")
public void topicInputHasText(String text) {
Assert.assertTrue("Wrong text in topic input " + infosystemsPage.getTopicInputText(), text.equalsIgnoreCase(infosystemsPage.getTopicInputText()));
}
@Then("^All displayed infosystems on 'infosystems' page have \"([^\"]*)\" associated topic$")
public void allDisplayedInfosystemsHaveTopic(String topic) throws Exception {
this.infosystemsPage.getFoundInfosystemsTopics().forEach(topics -> Assert.assertTrue("Found infosystem desn't have associated topic " + topic, topics.contains(topic.toUpperCase())));
}
}
package ee.ria.riha.loginpage;
import ee.ria.riha.pages.LoginPage;
import io.cucumber.java.en.And;
import io.cucumber.java.en.When;
......@@ -12,7 +13,7 @@ public class LoginPageSteps {
@When("^user selects 'Mobiil-ID' tab$")
public void userSelectsMobiilIdTab() {
this.loginPage.selectsMobiilIdTab();
this.loginPage.selectMobiilIdTab();
}
@And("^user enters 'isikukood' \"([^\"]*)\" and 'Telefoninumber' \"([^\"]*)\"$")
......
package ee.ria.riha.myinfosystemspage;
import ee.ria.riha.pages.MyInfosystemsPage;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.junit.Assert;
public class MyInfosystemsPageSteps {
MyInfosystemsPage myInfosystemsPage;
public MyInfosystemsPageSteps() {
this.myInfosystemsPage = new MyInfosystemsPage();
}
@And("^user clicks on 'täpsusta otsingut'$")
public void userClicksOnDetailedSearchLink() {
this.myInfosystemsPage.openDetailedSearchForm();
}
@And("^user enters search topic \"([^\"]*)\" and presses 'enter'$")
public void userSearchesByTopic(String topic) throws Exception {
this.myInfosystemsPage.searchByTopic(topic);
}
@And("^user clicks 'Lisa uus'$")
public void userClicksCreateNew() {
this.myInfosystemsPage.goToCreateNewInfosystemPage();
}
@And("^user enters name as \"([^\"]*)\" short name as \"([^\"]*)\" and purpose as \"([^\"]*)\"$")
public void userEntersNameShortNameAndPurpose(String name, String shortName, String purpose) {
this.myInfosystemsPage.enterNameSHortNameAndPurpose(name, shortName, purpose);
}
@When("^user clicks on \"([^\"]*)\" infosystem link$")
public void userClicksOnIfosystemLink(String infosystem) {
this.myInfosystemsPage.goToInfosystemPage(infosystem);
}
@Then("^All displayed infosystems on 'my infosystems' page have \"([^\"]*)\" associated topic$")
public void allDisplayedInfosystemsHaveTopic(String topic) {
this.myInfosystemsPage.getFoundInfosystemsTopics().forEach(topics -> Assert.assertTrue("Found infosystem desn't have associated topic " + topic, topics.contains(topic.toUpperCase())));
}
}
package ee.ria.riha.myinfosystemspage;
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"},
strict = false, plugin = {"pretty",
"json:target/cucumber_json_reports/my-infosystems-page.json",
"html:target/my-infosystems-page-html"},
glue = {"ee.ria.riha"})
public class MyInfosystemsPageTest {
}
Feature: Home page functionality
Background:
Given User is logged in to "https://riha-browser-ik.ci.kit" as "60001019906" using tel. number "00000766"
Scenario: User can select organization which he is representing in RIHA (RIHAKB-343)
Given User selects organization "Testasutus 2"
Then Organization name "Testasutus 2" is shown next to user's name
And page title is "Avaleht - Riigi infosüsteemi haldussüsteem RIHA"
\ No newline at end of file
Feature: Home page
Scenario Outline: Check page display
Given A user navigates to HomePage "<url>"
Then logo is displayed
And page title is "Avaleht - Riigi infosüsteemi haldussüsteem RIHA"
Examples:
| url |
| https://riha-browser-ik.ci.kit |
\ No newline at end of file
Feature: Login
Scenario Outline: Login to application
Scenario Outline: Login to application (RIHAKB-308)
Given A user navigates to HomePage "<url>"
And user clicks on login button
When user selects 'Mobiil-ID' tab
......
Feature: My organization infosystems page functionality
Background:
Given User is logged in to "https://riha-browser-ik.ci.kit" as "60001019906" using tel. number "00000766"
Scenario: User can search infosystem by keyword (RIHAKB-425)
Given User opens 'my organization infosystems page'
And user clicks on 'täpsusta otsingut'
And user enters search topic "x-tee alamsüsteem" and presses 'enter'
Then All displayed infosystems on 'my infosystems' page have "x-tee alamsüsteem" associated topic
When user clicks on "riha-test" infosystem link
Then "x-tee alamsüsteem" topic is present in associated topics list
When user clicks on "x-tee alamsüsteem" topic
Then All displayed infosystems on 'infosystems' page have "x-tee alamsüsteem" associated topic
And topic input has "x-tee alamsüsteem" text
# 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