forked from Zakaria/ZenProject
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 49af5e36d7 | |||
| af2bb3ca0e | |||
| d77499088f | |||
| 0e81fec560 | |||
| 1bc6cf564c | |||
| c03ae30e24 | |||
| d13a89e735 | |||
| 9cb8ca125e | |||
| 05e07626b1 | |||
| f146baa692 | |||
| 6add05fc69 | |||
| ed9847864a | |||
| 4a5405049c | |||
| 76acd5ae9e | |||
| 7ad5df5475 | |||
| 09c9801fc9 | |||
| 9777fa5e9a | |||
| 3c07bb12d6 | |||
| e8968b6243 | |||
| 8a5ab43be8 | |||
| 0ad5c13d36 | |||
| 9e4277a032 | |||
| d0fc65136e | |||
| 43936b1f15 |
50
BDDrepo/bddReports
Normal file
50
BDDrepo/bddReports
Normal file
File diff suppressed because one or more lines are too long
3
Jenkinsfile
vendored
3
Jenkinsfile
vendored
@ -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
72
pom.xml
@ -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>
|
||||||
|
|||||||
@ -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:37 AM</span> / <span>00:00:00:000</span>
|
<span>1:35:55 AM</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:37 AM</span>
|
<span class='badge badge-success'>10.26.2024 1:35:55 AM</span>
|
||||||
<span class='badge badge-danger'>09.29.2024 1:21:37 AM</span>
|
<span class='badge badge-danger'>10.26.2024 1:35:55 AM</span>
|
||||||
<span class='badge badge-default'>00:00:00:000</span>
|
<span class='badge badge-default'>00:00:00:000</span>
|
||||||
· <span class='uri-anchor badge badge-default'>#test-id=1</span>
|
· <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">
|
||||||
|
|||||||
8
src/main/java/features/HomePage.feature
Normal file
8
src/main/java/features/HomePage.feature
Normal 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"
|
||||||
35
src/main/java/stepDefinition/StepDefinition.java
Normal file
35
src/main/java/stepDefinition/StepDefinition.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
10
src/main/java/testNGRunner/TestRunner.java
Normal file
10
src/main/java/testNGRunner/TestRunner.java
Normal 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 {
|
||||||
|
|
||||||
|
}
|
||||||
@ -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));
|
||||||
|
|||||||
36
src/main/java/zacksolutions/base/JokesAPI.java
Normal file
36
src/main/java/zacksolutions/base/JokesAPI.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1 @@
|
|||||||
url=https://zenful.cloud/
|
url=https://zenful.cloud/
|
||||||
|
|
||||||
browserC= chrome
|
|
||||||
browserF= firefox
|
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
11
testCucumber.xml
Normal 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>
|
||||||
|
|
||||||
15
testng.xml
15
testng.xml
@ -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>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user