Compare commits

...

24 Commits
main ... main

Author SHA1 Message Date
49af5e36d7 Delete src/test/java/zacksolutions/BrokenLinks.java
Some checks are pending
jenkins/ZenProject/pipeline/head Build queued...
2024-11-25 00:29:08 +00:00
af2bb3ca0e Parallel brokenLinks test
Some checks are pending
jenkins/ZenProject/pipeline/head Build queued...
2024-11-16 15:34:14 -05:00
d77499088f BDDpluging_RegressionTest
All checks were successful
jenkins/ZenProject/pipeline/head This commit looks good
2024-10-08 03:24:23 -04:00
0e81fec560 BDDpluging, reports, and tags
Some checks failed
jenkins/ZenProject/pipeline/head There was a failure building this commit
2024-10-08 03:16:03 -04:00
1bc6cf564c fix: 24 - CucumberFrameWorkDone
Some checks failed
jenkins/ZenProject/pipeline/head There was a failure building this commit
2024-10-04 03:30:23 -04:00
c03ae30e24 fix: 24 - CucumberFrameWorkDone
Some checks failed
jenkins/ZenProject/pipeline/head There was a failure building this commit
2024-10-04 03:09:56 -04:00
d13a89e735 fix: 24 - adding CucumberFramework
All checks were successful
jenkins/ZenProject/pipeline/head This commit looks good
2024-10-03 17:38:00 -04:00
9cb8ca125e fix: 24 - RemoteWebDriver+ passing testng to POM
All checks were successful
jenkins/ZenProject/pipeline/head This commit looks good
2024-10-02 22:17:07 -04:00
05e07626b1 fix: 23 - RemoteWebDriver+ passing testng to POM
All checks were successful
jenkins/ZenProject/pipeline/head This commit looks good
2024-10-02 19:29:07 -04:00
f146baa692 fix: 23 - RemoteWebDriver
Some checks failed
jenkins/ZenProject/pipeline/head There was a failure building this commit
2024-10-02 19:14:32 -04:00
6add05fc69 fix: 22
All checks were successful
jenkins/ZenProject/pipeline/head This commit looks good
2024-10-02 11:22:57 -04:00
ed9847864a fix: 21 finally fix with getter methods
All checks were successful
jenkins/ZenProject/pipeline/head This commit looks good
2024-10-01 22:23:12 -04:00
4a5405049c fix: 20
All checks were successful
jenkins/ZenProject/pipeline/head This commit looks good
2024-10-01 21:47:17 -04:00
76acd5ae9e fix: 19
All checks were successful
jenkins/ZenProject/pipeline/head This commit looks good
2024-10-01 21:42:45 -04:00
7ad5df5475 fix: 18
All checks were successful
jenkins/ZenProject/pipeline/head This commit looks good
2024-10-01 21:40:12 -04:00
09c9801fc9 fix: 17
Some checks reported errors
jenkins/ZenProject/pipeline/head Something is wrong with the build of this commit
2024-09-30 23:05:12 -04:00
9777fa5e9a fix: 16
Some checks failed
jenkins/ZenProject/pipeline/head There was a failure building this commit
2024-09-30 22:50:46 -04:00
3c07bb12d6 fix: 15
All checks were successful
jenkins/ZenProject/pipeline/head This commit looks good
2024-09-30 22:36:44 -04:00
e8968b6243 fix: 14
Some checks failed
jenkins/ZenProject/pipeline/head There was a failure building this commit
2024-09-30 22:33:07 -04:00
8a5ab43be8 fix: 13 - testing firefox
Some checks failed
jenkins/ZenProject/pipeline/head There was a failure building this commit
2024-09-29 17:15:49 -04:00
0ad5c13d36 fix: 12 - testing firefox
Some checks failed
jenkins/ZenProject/pipeline/head There was a failure building this commit
2024-09-29 17:02:16 -04:00
9e4277a032 fix: 11 - Updating Jenkinsfile
All checks were successful
jenkins/ZenProject/pipeline/head This commit looks good
2024-09-29 16:29:56 -04:00
d0fc65136e fix: 10 - Updating Jenkinsfile
Some checks failed
Zenful/ZenProject/pipeline/head There was a failure building this commit
Zakaria/ZenProject/pipeline/head There was a failure building this commit
jenkins/ZenProject/pipeline/head There was a failure building this commit
2024-09-29 01:58:06 -04:00
43936b1f15 fix: 10 - Updating Jenkinsfile
Some checks failed
Zenful/ZenProject/pipeline/head There was a failure building this commit
Zakaria/ZenProject/pipeline/head There was a failure building this commit
2024-09-29 01:53:40 -04:00
14 changed files with 335 additions and 69 deletions

50
BDDrepo/bddReports Normal file

File diff suppressed because one or more lines are too long

3
Jenkinsfile vendored
View File

@ -2,12 +2,11 @@ pipeline {
agent { agent {
label "agent_locke" label "agent_locke"
} }
stages { stages {
stage('Build') { stage('Build') {
steps { steps {
// This runs the Maven test phase // This runs the Maven test phase
sh 'mvn test' sh 'mvn test -P Regression'
} }
} }
} }

72
pom.xml
View File

@ -14,7 +14,61 @@
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<profiles>
<profile>
<id>Regression</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>Smoke</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testCucumber.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
<dependencies> <dependencies>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.18.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.9.2</version>
</dependency>
<dependency> <dependency>
<groupId>com.aventstack</groupId> <groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId> <artifactId>extentreports</artifactId>
@ -63,6 +117,22 @@
<artifactId>log4j-core</artifactId> <artifactId>log4j-core</artifactId>
<version>2.24.0</version> <version>2.24.0</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.19.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>7.19.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.14.1</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -35,7 +35,7 @@
<a href="#"><span class="badge badge-primary">Zenful</span></a> <a href="#"><span class="badge badge-primary">Zenful</span></a>
</li> </li>
<li class="m-r-10"> <li class="m-r-10">
<a href="#"><span class="badge badge-primary">Sep 29, 2024 01:21:35 AM</span></a> <a href="#"><span class="badge badge-primary">Oct 26, 2024 01:35:47 AM</span></a>
</li> </li>
</ul> </ul>
</div> </div>
@ -81,7 +81,7 @@
<div class="test-detail"> <div class="test-detail">
<p class="name">Test msg</p> <p class="name">Test msg</p>
<p class="text-sm"> <p class="text-sm">
<span>1:21:37AM</span> / <span>00:00:00:000</span> <span>1:35:55AM</span> / <span>00:00:00:000</span>
<span class="badge pass-bg log float-right">Pass</span> <span class="badge pass-bg log float-right">Pass</span>
</p> </p>
</div> </div>
@ -90,8 +90,8 @@
<div class="p-v-10"> <div class="p-v-10">
<div class="info"> <div class="info">
<h5 class="test-status text-pass">Test msg</h5> <h5 class="test-status text-pass">Test msg</h5>
<span class='badge badge-success'>09.29.2024 1:21:37AM</span> <span class='badge badge-success'>10.26.2024 1:35:55AM</span>
<span class='badge badge-danger'>09.29.2024 1:21:37AM</span> <span class='badge badge-danger'>10.26.2024 1:35:55AM</span>
<span class='badge badge-default'>00:00:00:000</span> <span class='badge badge-default'>00:00:00:000</span>
&middot; <span class='uri-anchor badge badge-default'>#test-id=1</span> &middot; <span class='uri-anchor badge badge-default'>#test-id=1</span>
<span title='Skip to the next failed step' class='badge badge-danger pointer float-right ne ml-1'><i class="fa fa-fast-forward"></i></span> <span title='Skip to the next failed step' class='badge badge-danger pointer float-right ne ml-1'><i class="fa fa-fast-forward"></i></span>
@ -115,13 +115,13 @@
<div class="col-md-3"> <div class="col-md-3">
<div class="card"><div class="card-body"> <div class="card"><div class="card-body">
<p class="m-b-0">Started</p> <p class="m-b-0">Started</p>
<h3>Sep 29, 2024 01:21:35 AM</h3> <h3>Oct 26, 2024 01:35:47 AM</h3>
</div></div> </div></div>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<div class="card"><div class="card-body"> <div class="card"><div class="card-body">
<p class="m-b-0">Ended</p> <p class="m-b-0">Ended</p>
<h3>Sep 29, 2024 01:21:37 AM</h3> <h3>Oct 26, 2024 01:35:56 AM</h3>
</div></div> </div></div>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">

View File

@ -0,0 +1,8 @@
Feature: Home page of the application
@Smoke
Scenario: Leave a comment into Zenful.cloud
Given Initialize the remote webdriver Firefox
And navigate to "https://zenful.cloud"
When User type text into the text box and hit click
Then Text is displayed "True"

View File

@ -0,0 +1,35 @@
package stepDefinition;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import zacksolutions.base.Initialization;
import zacksolutions.pages.HomePage;
import java.io.IOException;
public class StepDefinition extends Initialization {
@Given("Initialize the remote webdriver Firefox")
public void initializeTheRemoteWebdriverFirefox() {
BrowserInit("firefox");
}
@Given("navigate to {string}")
public void navigate_to(String url) {
// Write code here that turns the phrase above into concrete actions
driver.get(url);
}
@When("User type text into the text box and hit click")
public void user_type_text_into_the_text_box_and_hit_click() throws IOException, InterruptedException {
// Write code here that turns the phrase above into concrete actions
HomePage hp = new HomePage();
hp.insertText();
}
@Then("Text is displayed {string}")
public void text_is_displayed(String string) {
// Write code here that turns the phrase above into concrete actions
HomePage hp = new HomePage();
hp.textConfirmation();
}
}

View File

@ -0,0 +1,10 @@
package testNGRunner;
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
@CucumberOptions(features = "src/main/java/features", glue = "stepDefinition", monochrome = false, plugin = { "pretty",
"html:BDDrepo/bddReports" }, tags = "@Smoke")
public class TestRunner extends AbstractTestNGCucumberTests {
}

View File

@ -2,19 +2,23 @@ package zacksolutions.base;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration; import java.time.Duration;
import java.util.Properties; import java.util.Properties;
import com.aventstack.extentreports.ExtentTest; import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.reporter.ExtentSparkReporter; import com.aventstack.extentreports.reporter.ExtentSparkReporter;
import com.aventstack.extentreports.ExtentReports; import com.aventstack.extentreports.ExtentReports;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Parameters;
public class Initialization { public class Initialization {
// let's set up our variables // let's set up our variables
// private static ThreadLocal<WebDriver> driver = new ThreadLocal<>();
public static WebDriver driver; public static WebDriver driver;
public static Properties prop; public static Properties prop;
public static ExtentReports extent; public static ExtentReports extent;
@ -36,7 +40,8 @@ public class Initialization {
} }
public void BrowserInit() { @Parameters("browser")
public void BrowserInit(String browser) {
// our EXTENTREPORTS SETUP! // our EXTENTREPORTS SETUP!
String path = System.getProperty("user.dir") + "/reports/index.html"; String path = System.getProperty("user.dir") + "/reports/index.html";
@ -47,31 +52,50 @@ public class Initialization {
extent.attachReporter(spark); extent.attachReporter(spark);
extent.setSystemInfo("Tester ID: ", "Sami"); extent.setSystemInfo("Tester ID: ", "Sami");
// conditioning our WebDriver with an if statement if (browser.equalsIgnoreCase("chrome")) {
String browsername = prop.getProperty("browserC");
// launching FireFox
if (browsername.equalsIgnoreCase("firefox")) {
// System.setProperty("web-driver.gecko.driver","user.dir" +
// "/drivers/geckodriver");
// driver = new FirefoxDriver();
driver.get(prop.getProperty("url"));
}
// launching Chrome
if (browsername.equalsIgnoreCase("chrome")) {
// System.setProperty("web-driver.gecko.driver", "user.dir" +
// "/drivers/chromedriver");
// driver = new ChromeDriver();
ChromeOptions options = new ChromeOptions(); ChromeOptions options = new ChromeOptions();
driver = new ChromeDriver(options); try {
options.addArguments("--no-sandbox"); driver = new RemoteWebDriver(new URL("http://192.168.1.215:4444/wd/hub"), options);
options.addArguments("--disable-dev-shm-usage"); } catch (MalformedURLException e) {
options.addArguments("--headless"); e.printStackTrace();
options.addArguments("--remote-debugging-port=9222"); // TODO: handle exception
options.setBinary("/usr/bin/google-chrome"); }
driver.get(prop.getProperty("url")); } else if (browser.equalsIgnoreCase("firefox")) {
FirefoxOptions options = new FirefoxOptions();
try {
driver = new RemoteWebDriver(new URL("http://192.168.1.215:4444/wd/hub"), options);
} catch (MalformedURLException e) {
// TODO: handle exception
e.printStackTrace();
}
} else {
throw new IllegalArgumentException("Unsupported browser: " + browser);
} }
//
// // conditioning our WebDriver with an if statement
// String browsername = prop.getProperty("browserF");
//
// // launching FireFox
// if (browsername.equalsIgnoreCase("firefox")) {
// // System.setProperty("web-driver.gecko.driver","user.dir" +
// // "/drivers/geckodriver");
// // driver = new FirefoxDriver();
// FirefoxOptions options = new FirefoxOptions();
// options.addArguments("--headless");
// driver = new FirefoxDriver(options);
// }
//
// // launching Chrome
// if (browsername.equalsIgnoreCase("chrome")) {
// // System.setProperty("web-driver.gecko.driver", "user.dir" +
// // "/drivers/chromedriver");
// // driver = new ChromeDriver();
// ChromeOptions options = new ChromeOptions();
// options.addArguments("--headless");
// driver = new ChromeDriver(options);
// }
driver.get(prop.getProperty("url"));
driver.manage().window().maximize(); driver.manage().window().maximize();
driver.manage().deleteAllCookies(); driver.manage().deleteAllCookies();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5)); driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));

View File

@ -0,0 +1,36 @@
package zacksolutions.base;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* JokesAPI
*/
public class JokesAPI {
private String setup;
private String punchline;
public void fetchJokes() throws IOException {
URL apiUrl = new URL("https://official-joke-api.appspot.com/jokes/random");
HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection();
connection.setRequestProperty("accept", "application/json");
InputStream responseStream = connection.getInputStream();
ObjectMapper mapper = new ObjectMapper();
JsonNode root = mapper.readTree(responseStream);
this.setup = root.path("setup").asText();
this.punchline = root.path("punchline").asText();
}
public String getSetup(){
return setup;
}
public String getPunchline(){
return punchline;
}
}

View File

@ -1,5 +1 @@
url=https://zenful.cloud/ url=https://zenful.cloud/
browserC= chrome
browserF= firefox

View File

@ -3,32 +3,46 @@ package zacksolutions.pages;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import zacksolutions.base.Initialization; import zacksolutions.base.Initialization;
import zacksolutions.base.JokesAPI;
import java.io.IOException;
import java.time.Duration;
public class HomePage extends Initialization { public class HomePage extends Initialization {
//Using PageFactory Object Model we get our elemets // Using PageFactory Object Model we get our elemets
@FindBy(id="message") @FindBy(id = "message")
WebElement message; WebElement message;
@FindBy(css="button[type='submit']") @FindBy(css = "button[type='submit']")
WebElement button; WebElement button;
@FindBy(css="tbody tr:nth-child(1) td:nth-child(1)") @FindBy(xpath = "//tbody/tr[1]/td[1]")
WebElement ConfirmText; WebElement ConfirmText;
//Initialization // Initialization
public HomePage(){ public HomePage() {
PageFactory.initElements(driver, this); PageFactory.initElements(driver, this);
} }
//Actions // Actions
public void insertText() throws InterruptedException { public void insertText() throws InterruptedException, IOException {
test = extent.createTest("Test msg"); JokesAPI jokesAPI = new JokesAPI();
message.sendKeys("4 8 15 16 23 42"); jokesAPI.fetchJokes();
button.click(); String setup = jokesAPI.getSetup();
extent.flush(); String punchline = jokesAPI.getPunchline();
} test = extent.createTest("Test msg");
public String textConfirmation(){ message.sendKeys(setup + " ==> " + punchline);
return ConfirmText.getText(); button.click();
} extent.flush();
}
public void textConfirmation() {
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15)); // Adjust the timeout as needed
wait.until(ExpectedConditions.visibilityOf(ConfirmText));
String joke = ConfirmText.getText();
System.out.println(joke);
}
} }

View File

@ -1,12 +1,14 @@
package zacksolutions; package zacksolutions;
import org.testng.Assert;
import org.testng.annotations.AfterTest; import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import zacksolutions.base.Initialization; import zacksolutions.base.Initialization;
import zacksolutions.pages.HomePage; import zacksolutions.pages.HomePage;
import java.io.IOException;
public class HomePageTest extends Initialization { public class HomePageTest extends Initialization {
HomePage homePage; HomePage homePage;
@ -15,18 +17,22 @@ public class HomePageTest extends Initialization {
super(); super();
} }
@Parameters("browser")
@BeforeTest @BeforeTest
public void setUp() { public void setUp(String browser) {
BrowserInit(); BrowserInit(browser);
homePage = new HomePage(); homePage = new HomePage();
System.out.println("Starting " + browser);
} }
@Test @Test
public void TextTest() throws InterruptedException { public void TextTest() throws InterruptedException, IOException {
HomePage hp = new HomePage(); HomePage hp = new HomePage();
hp.insertText(); hp.insertText();
/*
hp.textConfirmation(); hp.textConfirmation();
Assert.assertEquals(hp.textConfirmation(), "4 8 15 16 23 42"); */
System.out.println("Job is done, please check this link: " + prop.getProperty("url"));
} }
@AfterTest @AfterTest

11
testCucumber.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="All Test Suite" thread-count="1" parallel="tests">
<test name="CucumberTest">
<classes>
<class name="testNGRunner.TestRunner">
</class>
</classes>
</test>
</suite>

View File

@ -1,12 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="All Test Suite"> <suite name="All Test Suite" thread-count="1" parallel="tests">
<test verbose="2" preserve-order="true" name="/home/ilyes/SeleniumPractice/Zenful"> <test name="FireFoxTest">
<parameter name="browser" value="firefox"/>
<classes>
<class name="zacksolutions.HomePageTest">
</class>
</classes>
</test>
<test name="ChromeTest">
<parameter name="browser" value="chrome"/>
<classes> <classes>
<class name="zacksolutions.HomePageTest"> <class name="zacksolutions.HomePageTest">
<methods><include name="TextTest"/>
</methods>
</class> </class>
</classes> </classes>
</test> </test>
</suite> </suite>