-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from mohanachandran-s/develop
Framework setup for UI automation of INJI-WEB
- Loading branch information
Showing
10 changed files
with
292 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
inji-web-test/src/test/resources/featurefiles/helppage.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
8 changes: 8 additions & 0 deletions
8
inji-web-test/src/test/resources/featurefiles/homepage.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |