Compare commits

...

35 Commits

Author SHA1 Message Date
Zakaria 49af5e36d7 Delete src/test/java/zacksolutions/BrokenLinks.java 2024-11-25 00:29:08 +00:00
Sami af2bb3ca0e Parallel brokenLinks test 2024-11-16 15:34:14 -05:00
Sami d77499088f BDDpluging_RegressionTest 2024-10-08 03:24:23 -04:00
Sami 0e81fec560 BDDpluging, reports, and tags 2024-10-08 03:16:03 -04:00
Sami 1bc6cf564c fix: 24 - CucumberFrameWorkDone 2024-10-04 03:30:23 -04:00
Sami c03ae30e24 fix: 24 - CucumberFrameWorkDone 2024-10-04 03:09:56 -04:00
Sami d13a89e735 fix: 24 - adding CucumberFramework 2024-10-03 17:38:00 -04:00
Sami 9cb8ca125e fix: 24 - RemoteWebDriver+ passing testng to POM 2024-10-02 22:17:07 -04:00
Sami 05e07626b1 fix: 23 - RemoteWebDriver+ passing testng to POM 2024-10-02 19:29:07 -04:00
Sami f146baa692 fix: 23 - RemoteWebDriver 2024-10-02 19:14:32 -04:00
Sami 6add05fc69 fix: 22 2024-10-02 11:22:57 -04:00
Sami ed9847864a fix: 21 finally fix with getter methods 2024-10-01 22:23:12 -04:00
Sami 4a5405049c fix: 20 2024-10-01 21:47:17 -04:00
Sami 76acd5ae9e fix: 19 2024-10-01 21:42:45 -04:00
Sami 7ad5df5475 fix: 18 2024-10-01 21:40:12 -04:00
Sami 09c9801fc9 fix: 17 2024-09-30 23:05:12 -04:00
Sami 9777fa5e9a fix: 16 2024-09-30 22:50:46 -04:00
Sami 3c07bb12d6 fix: 15 2024-09-30 22:36:44 -04:00
Sami e8968b6243 fix: 14 2024-09-30 22:33:07 -04:00
Sami 8a5ab43be8 fix: 13 - testing firefox 2024-09-29 17:15:49 -04:00
Sami 0ad5c13d36 fix: 12 - testing firefox 2024-09-29 17:02:16 -04:00
Sami 9e4277a032 fix: 11 - Updating Jenkinsfile 2024-09-29 16:29:56 -04:00
Sami d0fc65136e fix: 10 - Updating Jenkinsfile 2024-09-29 01:58:06 -04:00
Sami 43936b1f15 fix: 10 - Updating Jenkinsfile 2024-09-29 01:53:40 -04:00
Sami 6fe7a83a5a fix: 9 - Updating Jenkinsfile 2024-09-29 01:22:17 -04:00
Sami c36e6e9336 fix: 8 - Updating Jenkinsfile 2024-09-29 01:08:07 -04:00
Sami bc25347655 fix: 7 - Updating Jenkinsfile 2024-09-29 01:00:40 -04:00
Sami a92c917c97 fix: 6 - Updating Jenkinsfile 2024-09-29 00:49:39 -04:00
Sami d730a1357d fix: 4 - Updating Jenkinsfile 2024-09-28 19:02:18 -04:00
Sami 54fbd3e326 fix: 4 - Updating Jenkinsfile 2024-09-28 18:32:03 -04:00
Sami f0dfc063e1 fix: 3 - Updating Jenkinsfile 2024-09-28 17:29:33 -04:00
Sami c72122fea2 fix: 2 - Updating Jenkinsfile 2024-09-28 17:24:58 -04:00
Sami df67108c10 fix: adding Jenkinsfile 2024-09-28 17:13:43 -04:00
Sami 72f873c8d8 fix: 4 - adding comments for test 2024-09-27 21:55:36 -04:00
Sami 4592c1d74e fix: 3 - adding comments for test 2024-09-27 21:44:53 -04:00
15 changed files with 378 additions and 79 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="openjdk-23" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" project-jdk-name="openjdk-23" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
File diff suppressed because one or more lines are too long
Vendored
+13
View File
@@ -0,0 +1,13 @@
pipeline {
agent {
label "agent_locke"
}
stages {
stage('Build') {
steps {
// This runs the Maven test phase
sh 'mvn test -P Regression'
}
}
}
}
+71 -1
View File
@@ -14,7 +14,61 @@
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</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>
<!-- 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>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
@@ -63,6 +117,22 @@
<artifactId>log4j-core</artifactId>
<version>2.24.0</version>
</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>
</project>
+7 -7
View File
@@ -35,7 +35,7 @@
<a href="#"><span class="badge badge-primary">Zenful</span></a>
</li>
<li class="m-r-10">
<a href="#"><span class="badge badge-primary">Sep 27, 2024 10:13:21 AM</span></a>
<a href="#"><span class="badge badge-primary">Oct 26, 2024 01:35:47 AM</span></a>
</li>
</ul>
</div>
@@ -81,7 +81,7 @@
<div class="test-detail">
<p class="name">Test msg</p>
<p class="text-sm">
<span>10:13:26AM</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>
</p>
</div>
@@ -90,8 +90,8 @@
<div class="p-v-10">
<div class="info">
<h5 class="test-status text-pass">Test msg</h5>
<span class='badge badge-success'>09.27.2024 10:13:26AM</span>
<span class='badge badge-danger'>09.27.2024 10:13:26AM</span>
<span class='badge badge-success'>10.26.2024 1:35:55AM</span>
<span class='badge badge-danger'>10.26.2024 1:35:55AM</span>
<span class='badge badge-default'>00:00:00:000</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>
@@ -115,13 +115,13 @@
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Started</p>
<h3>Sep 27, 2024 10:13:21 AM</h3>
<h3>Oct 26, 2024 01:35:47 AM</h3>
</div></div>
</div>
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Ended</p>
<h3>Sep 27, 2024 10:13:26 AM</h3>
<h3>Oct 26, 2024 01:35:56 AM</h3>
</div></div>
</div>
<div class="col-md-3">
@@ -182,7 +182,7 @@ var timeline = {
<thead><tr class="bg-gray"><th>Name</th><th>Value</th></tr></thead>
<tbody>
<tr>
<td>Test Done By: </td>
<td>Tester ID: </td>
<td>Sami</td>
</tr>
</tbody>
+8
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"
@@ -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();
}
}
@@ -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 {
}
@@ -2,30 +2,35 @@ package zacksolutions.base;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;
import java.util.Properties;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.reporter.ExtentSparkReporter;
import com.aventstack.extentreports.ExtentReports;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Parameters;
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 Properties prop;
public static ExtentReports extent;
public static ExtentTest test;
public Initialization() {
// let's use the config.properties file to set up our global variables...
try {
prop = new Properties();
FileInputStream fis = new FileInputStream(System.getProperty("user.dir") + "/src/main/java/zacksolutions/config/config.properties");
FileInputStream fis = new FileInputStream(
System.getProperty("user.dir") + "/src/main/java/zacksolutions/config/config.properties");
prop.load(fis);
} catch (IOException e) {
@@ -35,8 +40,9 @@ public class Initialization {
}
public void BrowserInit() {
//our EXTENTREPORTS SETUP!
@Parameters("browser")
public void BrowserInit(String browser) {
// our EXTENTREPORTS SETUP!
String path = System.getProperty("user.dir") + "/reports/index.html";
ExtentSparkReporter spark = new ExtentSparkReporter(path);
@@ -44,21 +50,54 @@ public class Initialization {
spark.config().setReportName("Zenful");
extent = new ExtentReports();
extent.attachReporter(spark);
extent.setSystemInfo("Test Done By: ", "Sami");
//conditioning our WebDriver with an if statement
extent.setSystemInfo("Tester ID: ", "Sami");
String browsername = prop.getProperty("browserC");
if (browsername.equalsIgnoreCase("firefox")) {
System.setProperty("web-driver.gecko.driver","user.dir" + "/drivers/geckodriver");
driver = new FirefoxDriver();
driver.get(prop.getProperty("url"));
if (browser.equalsIgnoreCase("chrome")) {
ChromeOptions options = new ChromeOptions();
try {
driver = new RemoteWebDriver(new URL("http://192.168.1.215:4444/wd/hub"), options);
} catch (MalformedURLException e) {
e.printStackTrace();
// TODO: handle exception
}
if (browsername.equalsIgnoreCase("chrome")) {
System.setProperty("web-driver.gecko.driver", "user.dir" + "/drivers/chromedriver");
driver = new ChromeDriver();
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().deleteAllCookies();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
}
}
@@ -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;
}
}
@@ -1,5 +1 @@
url=https://zenful.cloud/
browserC= chrome
browserF= firefox
+25 -10
View File
@@ -3,31 +3,46 @@ package zacksolutions.pages;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
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.JokesAPI;
import java.io.IOException;
import java.time.Duration;
public class HomePage extends Initialization {
@FindBy(id="message")
// Using PageFactory Object Model we get our elemets
@FindBy(id = "message")
WebElement message;
@FindBy(css="button[type='submit']")
@FindBy(css = "button[type='submit']")
WebElement button;
@FindBy(css="tbody tr:nth-child(1) td:nth-child(1)")
@FindBy(xpath = "//tbody/tr[1]/td[1]")
WebElement ConfirmText;
//Initialization
public HomePage(){
// Initialization
public HomePage() {
PageFactory.initElements(driver, this);
}
//Actions
public void insertText() throws InterruptedException {
// Actions
public void insertText() throws InterruptedException, IOException {
JokesAPI jokesAPI = new JokesAPI();
jokesAPI.fetchJokes();
String setup = jokesAPI.getSetup();
String punchline = jokesAPI.getPunchline();
test = extent.createTest("Test msg");
message.sendKeys("4 8 15 16 23 42");
message.sendKeys(setup + " ==> " + punchline);
button.click();
extent.flush();
}
public String textConfirmation(){
return ConfirmText.getText();
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);
}
}
+16 -7
View File
@@ -1,33 +1,42 @@
package zacksolutions;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import zacksolutions.base.Initialization;
import zacksolutions.pages.HomePage;
import java.io.IOException;
public class HomePageTest extends Initialization {
HomePage homePage;
public HomePageTest(){
public HomePageTest() {
super();
}
@Parameters("browser")
@BeforeTest
public void setUp(){
BrowserInit();
public void setUp(String browser) {
BrowserInit(browser);
homePage = new HomePage();
System.out.println("Starting " + browser);
}
@Test
public void TextTest() throws InterruptedException {
public void TextTest() throws InterruptedException, IOException {
HomePage hp = new HomePage();
hp.insertText();
/*
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
public void tearDown(){
public void tearDown() {
driver.close();
}
}
+11
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>
+11 -4
View File
@@ -1,12 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="All Test Suite">
<test verbose="2" preserve-order="true" name="/home/ilyes/SeleniumPractice/Zenful">
<suite name="All Test Suite" thread-count="1" parallel="tests">
<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>
<class name="zacksolutions.HomePageTest">
<methods><include name="TextTest"/>
</methods>
</class>
</classes>
</test>
</suite>