Skip to content
Open
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
34 changes: 34 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Run Selenium Tests

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 18
uses: actions/setup-java@v3
with:
java-version: '18'
distribution: 'temurin'
- name: Install Google Chrome
run: |
chmod +x ./scripts/InstallChrome.sh
./scripts/InstallChrome.sh
- name: Run Tests with Maven
run: mvn test --file pom.xml
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
<version>7.7.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.epam.healenium/healenium-web -->
<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
<dependency>
<groupId>com.epam.healenium</groupId>
<artifactId>healenium-web</artifactId>
<version>3.3.1</version>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-http-jdk-client -->
<dependency>
Expand Down
4 changes: 4 additions & 0 deletions scripts/InstallChrome.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -ex
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
4 changes: 2 additions & 2 deletions src/test/java/pageobjects/swaglabs/HomePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public void applyFilter(String value) {
driver.findElement(By.xpath("//select[@class='product_sort_container']/option[@value='" + value + "']")).click();
}
//get the filter value
public String getAppliedFilter() {
return driver.findElement(By.xpath("//div[@class='right_component']/span/span")).getText();
public Boolean chkAppliedFilter(String filter) {
return driver.findElement(By.xpath("//span[contains(text(),'"+filter+"')]"))!=null;
}

public String getPageHeading() {
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/tests/SwagLabs/BaseTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tests.SwagLabs;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
Expand All @@ -19,10 +20,13 @@ public class BaseTest {

@BeforeClass
public void setupBeforeTest(){
WebDriverManager.chromedriver().setup();
this.options = new ChromeOptions();
this.options.addArguments("start-maximized");
this.options.addArguments("--no-sandbox");
this.options.addArguments("--disable-dev-shm-usage");
this.options.addArguments("--headless");
System.setProperty("webdriver.http.factory", "jdk-http-client");
System.setProperty("webdriver.chrome.driver","C:\\Users\\mujtaba.afzal\\Documents\\ChromeDriver\\chromedriver.exe");
this.driver = new ChromeDriver(this.options);
this.properties = UtilsConfig.getProperties("SwagLabs");
this.XPATH = UtilsConfig.getProperties("xpath");
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/tests/SwagLabs/HomePageTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void beforeEach(){
@Test(description = "Verify Filter should be applied successfully")
public void applyFilter(){
homePage.applyFilter(properties.getProperty("sort_filter"));
Assert.assertEquals(homePage.getAppliedFilter(), properties.getProperty("sort_filter_text"));
Assert.assertTrue(homePage.chkAppliedFilter(properties.getProperty("sort_filter_text")));
}
@Test(description = "Verify product page should be opened successfully")
public void goToProductPage(){
Expand Down