Skip to content

Commit

Permalink
Merge pull request #55 from mohanachandran-s/develop
Browse files Browse the repository at this point in the history
Framework setup for UI automation of INJI-WEB
  • Loading branch information
vijay151096 authored May 29, 2024
2 parents d20ae67 + e4ea2a5 commit f779e7f
Show file tree
Hide file tree
Showing 10 changed files with 292 additions and 0 deletions.
41 changes: 41 additions & 0 deletions inji-web-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
*.class
.mtj.tmp/
*.war
*.ear
hs_err_pid*
#ignored files

.springBeans
.metadata
.factorypath
.classpath
.project
.settings/
bin/
tmp/

logs/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.loadpath
.DS_Store
test.txt
.idea/
.settings/
.sonarlint/
.recommenders/
/.recommenders/

**/*.iml
*.log
src/logs/mosip-api-test.log
/target/
target/
test-output/
testng-report/
/reg
./reg
reports
55 changes: 55 additions & 0 deletions inji-web-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.mosip.uiautomation.injiweb</groupId>
<artifactId>inji-web-test</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cucumber.version>7.17.0</cucumber.version>
</properties>

<dependencies>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.43.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>${cucumber.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<!-- References to interface static methods are allowed only at source level 1.8 or above -->
<configuration>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
21 changes: 21 additions & 0 deletions inji-web-test/src/main/java/base/BasePage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package base;

import com.microsoft.playwright.Page;

public class BasePage {

Page page;

public BasePage(Page page) {
this.page = page;
}

public void clickOnElement(String locator) {
page.locator(locator).click();
}

public Boolean isElementIsVisible(String locator) {
return page.locator(locator).isVisible();
}

}
24 changes: 24 additions & 0 deletions inji-web-test/src/main/java/pages/HomePage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package pages;

import com.microsoft.playwright.Page;

import base.BasePage;

public class HomePage extends BasePage {

public HomePage(Page page) {
super(page);
}

public void clickOnHelp() {
clickOnElement("//a[text()='Help']");
}

public Boolean isLogoDisplayed() {
return isElementIsVisible("//img[@src='/static/media/inji-logo.3eee14d8592e46b14318.png']");
}

public Boolean isTextWordIsDisplayed() {
return isElementIsVisible("//a[text()='Help']");
}
}
25 changes: 25 additions & 0 deletions inji-web-test/src/test/java/runnerfiles/Runner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package runnerfiles;

import org.junit.runner.RunWith;

import io.cucumber.junit.Cucumber;
import io.cucumber.testng.CucumberOptions.SnippetType;
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(
features = {"src/test/resources/featurefiles"},
dryRun = !true,
glue = {"stepdefinitions", "utils"},
snippets = SnippetType.CAMELCASE,
monochrome = true,
plugin = {"pretty",
"html:reports",
"summary"}
//tags = "@smoke"
)

public class Runner extends AbstractTestNGCucumberTests{

}
55 changes: 55 additions & 0 deletions inji-web-test/src/test/java/stepdefinitions/StepDef.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

package stepdefinitions;

import org.junit.Assert;

import com.microsoft.playwright.Page;

import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import pages.HomePage;
import utils.DriverManager;

public class StepDef{

private String pageTitle;

Page page;
DriverManager driver;
HomePage homePage;

public StepDef(DriverManager driver) {
this.driver = driver;
page = driver.getPage();
homePage = new HomePage(page);
}

@Given("User gets the title of the page")
public void getTheTitleOfThePage() {
pageTitle = page.title();
}

@Then("Validate the title of the page")
public void validateTheTitleOfThePage() {
Assert.assertEquals(pageTitle, "INJI Web");
}

@Then("Verify that inji web logo is displayed")
public void verifyInjiWebLogoIsDisplayed() throws InterruptedException {
Thread.sleep(3000);
Assert.assertEquals(homePage.isLogoDisplayed(), true);
}

@When("User clicks on the help button")
public void clicksOnHelpButton() {
homePage.clickOnHelp();
}

@Then("Verify that text help is displayed on page")
public void verifiyTextHelpIsDisplayedOnPage() throws InterruptedException {
Thread.sleep(3000);
Assert.assertEquals(homePage.isTextWordIsDisplayed(), true);
}

}
37 changes: 37 additions & 0 deletions inji-web-test/src/test/java/utils/BaseTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package utils;

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;

import io.cucumber.java.After;
import io.cucumber.java.Before;

public class BaseTest{

public static Playwright playwright;
public static Browser browser;

DriverManager driver;

public BaseTest(DriverManager driver) {
this.driver = driver;
}

@Before
public void setup() {
playwright = Playwright.create();
browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false));
Page page = browser.newPage();
driver.setPage(page);
driver.getPage().navigate("https://inji.qa-inji.mosip.net/");
}

@After
public void tearDown() {
driver.getPage().close();
browser.close();
playwright.close();
}
}
16 changes: 16 additions & 0 deletions inji-web-test/src/test/java/utils/DriverManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package utils;

import com.microsoft.playwright.Page;

public class DriverManager {

public Page page;

public Page getPage() {
return page;
}

public void setPage(Page page) {
this.page = page;
}
}
10 changes: 10 additions & 0 deletions inji-web-test/src/test/resources/featurefiles/helppage.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: Inji web help page testing

@regression @verifyHelpPage
Scenario: Navigating to help page and verfying it

Given User gets the title of the page
Then Validate the title of the page
When User clicks on the help button
Then Verify that text help is displayed on page
And Verify that inji web logo is displayed
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Feature: Inji web homepage testing

@smoke @verifyingHomepage
Scenario: Verify the Inji web homepage

Given User gets the title of the page
Then Validate the title of the page
And Verify that inji web logo is displayed

0 comments on commit f779e7f

Please sign in to comment.