This commit is contained in:
@@ -9,14 +9,11 @@ import java.util.Properties;
|
||||
import com.aventstack.extentreports.ExtentTest;
|
||||
import com.aventstack.extentreports.reporter.ExtentSparkReporter;
|
||||
import com.aventstack.extentreports.ExtentReports;
|
||||
import io.github.bonigarcia.wdm.WebDriverManager;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.chrome.ChromeOptions;
|
||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||
import org.openqa.selenium.firefox.FirefoxOptions;
|
||||
import org.openqa.selenium.remote.DesiredCapabilities;
|
||||
import org.openqa.selenium.remote.RemoteWebDriver;
|
||||
import org.testng.annotations.Parameters;
|
||||
|
||||
public class Initialization {
|
||||
// let's set up our variables
|
||||
@@ -42,7 +39,8 @@ public class Initialization {
|
||||
|
||||
}
|
||||
|
||||
public void BrowserInit() {
|
||||
@Parameters("browser")
|
||||
public void BrowserInit(String browser) {
|
||||
// our EXTENTREPORTS SETUP!
|
||||
|
||||
String path = System.getProperty("user.dir") + "/reports/index.html";
|
||||
@@ -53,28 +51,49 @@ public class Initialization {
|
||||
extent.attachReporter(spark);
|
||||
extent.setSystemInfo("Tester ID: ", "Sami");
|
||||
|
||||
// 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();
|
||||
if (browser.equalsIgnoreCase("chrome")) {
|
||||
ChromeOptions options = new ChromeOptions();
|
||||
options.addArguments("--headless");
|
||||
driver = new ChromeDriver(options);
|
||||
try {
|
||||
driver = new RemoteWebDriver(new URL("http://192.168.1.215:4444/wd/hub"), options);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
// TODO: handle exception
|
||||
}
|
||||
} 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();
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
url=https://zenful.cloud/
|
||||
|
||||
browserC= chrome
|
||||
browserF= firefox
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
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;
|
||||
@@ -17,19 +17,17 @@ public class HomePageTest extends Initialization {
|
||||
super();
|
||||
}
|
||||
|
||||
@Parameters("browser")
|
||||
@BeforeTest
|
||||
public void setUp() {
|
||||
BrowserInit();
|
||||
public void setUp(String browser) {
|
||||
BrowserInit(browser);
|
||||
homePage = new HomePage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TextTest() throws InterruptedException, IOException {
|
||||
System.out.println(driver.getTitle());
|
||||
HomePage hp = new HomePage();
|
||||
hp.insertText();
|
||||
hp.textConfirmation();
|
||||
// Assert.assertEquals(hp.textConfirmation(), "4 8 15 16 23 42");
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
|
||||
Reference in New Issue
Block a user