Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate Non Conformity Work Flow Test Case with Selenium and Cucumber using Page Object Model design #140

Merged
merged 1 commit into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/nonConformityWorkFlow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Non Conformity WorkFlow
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Checkout openelis qaframework
uses: actions/checkout@v2
with:
repository: ${{github.repository}}
- name: Start the Remote web driver in docker
run: |
docker-compose up -d chrome
- name: Sleep for 3 minutes
run: sleep 3m
shell: bash
- name: Run and Publish Openelis QA
run: |
mvn clean install -DskipTests=true
mvn test -Dcucumber.filter.tags='@nonConformity'
19 changes: 19 additions & 0 deletions src/features/openelis/nonConformityWorkflow.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: Non Conformity workflow

Background:
Given User Logs in to Home Page and goes to Non Conformity Report Page
Then User Selects Non Conformity report from main menu

@nonConformity
Scenario Outline: Search Non Conformity report
When User Selects search by --> Lab No dropdown option
Then User enters accession number "<accessionNumber>"
And User checks the affected specimen
Then User clicks go to NCE reporting form button
And Report date default is set to current date
And Report date can be modified

Examples:
| accessionNumber |
| 20210000000003761 |

2 changes: 2 additions & 0 deletions src/test/java/org/openelisglobal/qaframework/RunTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ public class HOOK {
public static final String WORKPLAN = "@workplan";

public static final String ADD_BATCH_ORDERS = "@addBatchOrders";

public static final String NON_CONFORMITY = "@nonConformity";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package org.openelisglobal.qaframework.automation;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import io.cucumber.java.After;
import io.cucumber.java.Before;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.openelisglobal.qaframework.RunTest;
import org.openelisglobal.qaframework.automation.page.AddOrderPage;
import org.openelisglobal.qaframework.automation.page.HomePage;
import org.openelisglobal.qaframework.automation.page.LoginPage;
import org.openelisglobal.qaframework.automation.page.NonConformityPage;
import org.openelisglobal.qaframework.automation.test.TestBase;

public class NonConformitySteps extends TestBase {

private static final String ACCESSION_NUMBER = "20210000000003761";

private LoginPage loginPage;

private HomePage homePage;

private NonConformityPage nonConformityPage;

private AddOrderPage addOrderPage;

@Before(RunTest.HOOK.NON_CONFORMITY)
public void setLoginPage() {
System.out.println("....Non Conformity......");
loginPage = new LoginPage(getWebDriver());
}

@After(RunTest.HOOK.NON_CONFORMITY)
public void destroy() {
quit();
}

@Given("User Logs in to Home Page and goes to Non Conformity Report Page")
public void userLogsInToHomePageAndGoesToNonConformityReportPage() throws InterruptedException {
homePage = loginPage.goToHomePage();
Thread.sleep(100);
}

@Then("User Selects Non Conformity report from main menu")
public void userSelectsNonConformityReportFromMainMenu() throws InterruptedException {
nonConformityPage = homePage.goToNonConformityReport();
assertTrue(nonConformityPage.containsText("Report Non-Conforming Event (NCE)"));
assertTrue(nonConformityPage.searchSelectExists());
assertTrue(nonConformityPage.searchFieldExists());
assertTrue(nonConformityPage.searchButtonExists());
assertEquals(nonConformityPage.searchButtonDisabledAttribute(), "true");
Thread.sleep(1000);
}

@When("User Selects search by --> Lab No dropdown option")
public void userSelectsSearchByLabNoDropdownOption() throws InterruptedException {
homePage = nonConformityPage.goToHomePage();
/** initialise order data **/
addOrderPage = homePage.goToAddOrderPage();
addOrderPage.innitialiseData(ACCESSION_NUMBER);
homePage = addOrderPage.goToHomePage();
if (homePage.alertPresent()) {
homePage.acceptAlert();
}

nonConformityPage = homePage.goToNonConformityReport();
nonConformityPage.selectCriteriaSelect("5. Lab No");
}

@Then("User enters accession number {string}")
public void userEntersAccessionNumber(String labNo) throws InterruptedException {
nonConformityPage.enterSearchText(labNo);
assertNull(nonConformityPage.searchButtonDisabledAttribute());
nonConformityPage.clickSearchButton();
Thread.sleep(1000);
}

@And("User checks the affected specimen")
public void userChecksTheAffectedSpecimen() {
nonConformityPage.checkAffectedSpecimen();
}

@Then("User clicks go to NCE reporting form button")
public void userClicksGoToNCEReportingFormButton() throws InterruptedException {
nonConformityPage.clickNCEButton();

}

@And("Report date default is set to current date")
public void reportDateDefaultIsSetToCurrentDate() {
}

@And("Report date can be modified")
public void reportDateCanBeModified() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public class HomePage extends Page {

private static final By LOG_OUT_BUTTON = By.xpath("//*[@id=\"logout-form\"]/div/input[1]");

private static final By FIRST_LEVEL_MENU_NON_CONFORMITY = By.id("menu_nonconformity");
private static final By SECOND_LEVEL_MENU_NON_CONFORMITY_REPORT = By.id("menu_non_conforming_report");

public HomePage(Page page) {
super(page);
}
Expand Down Expand Up @@ -190,4 +193,10 @@ public LoginPage ClickLogOut() {
clickOn(LOG_OUT_BUTTON);
return new LoginPage(getDriver());
}

public NonConformityPage goToNonConformityReport(){
hoverOn(FIRST_LEVEL_MENU_NON_CONFORMITY);
clickOn(SECOND_LEVEL_MENU_NON_CONFORMITY_REPORT);
return new NonConformityPage(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.openelisglobal.qaframework.automation.page;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

public class NonConformityPage extends Page {

private static final String PAGE_PATH = "/ReportNonConformingEvent";

private static final String PATH_HOME = "/Dashboard";

private static final By SEARCH_CRITERIA_SELECT = By.id("searchCriteria");

private static final By SEARCH_FIELD = By.id("searchValue");

private static final By SEARCH_BUTTON = By.id("searchButtonId");

private static final By AFFECTED_SPECIMEN_CHECKBOX = By.xpath("//*[@id=\"sample-\"]/tbody/tr[2]/td[1]/input");

private static final By NCE_BUTTON = By.id("goToNCEForm");

public NonConformityPage(Page parent) {
super(parent);
}

@Override
public String getPageUrl() {
return PAGE_PATH;
}

public HomePage goToHomePage() {
this.goToPage(PATH_HOME);
return new HomePage(this);
}

public boolean searchSelectExists() {
return hasElement(SEARCH_CRITERIA_SELECT);
}

public boolean searchFieldExists() {
return hasElement(SEARCH_FIELD);
}

public boolean searchButtonExists() {
return hasElement(SEARCH_BUTTON);
}

public String searchButtonDisabledAttribute() {
return findElement(SEARCH_BUTTON).getAttribute("disabled");
}

public void selectCriteriaSelect(String option) {
By FIELD_OPTION = By.tagName("option");
clickOn(SEARCH_CRITERIA_SELECT);
List<WebElement> elements = findElement(SEARCH_CRITERIA_SELECT).findElements(FIELD_OPTION);

for (WebElement element : elements) {
if (element.getText().equals(option)) {
element.click();
break;
}
}
}

public void enterSearchText(String searchQuery) {
setText(SEARCH_FIELD, searchQuery);
}
public void clickSearchButton(){
clickOn(SEARCH_BUTTON);
}

public void checkAffectedSpecimen() {
clickOn(AFFECTED_SPECIMEN_CHECKBOX);
}

public void clickNCEButton() {
clickOn(NCE_BUTTON);
}

}