diff --git a/.idea/misc.xml b/.idea/misc.xml index e122dea..30d7e2b 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ - + \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..a8b9e43 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,13 @@ +pipeline { + agent any + + stages { + stage('Build') { + steps { + // This runs the Maven test phase + sh 'mvn test' + } + } + } +} + diff --git a/reports/index.html b/reports/index.html index 4aef98f..4f8ff7f 100644 --- a/reports/index.html +++ b/reports/index.html @@ -35,7 +35,7 @@ Zenful
  • -Sep 27, 2024 10:13:21 AM +Sep 28, 2024 04:50:12 PM
  • @@ -81,7 +81,7 @@

    Test msg

    - 10:13:26 AM / 00:00:00:000 + 4:50:15 PM / 00:00:00:000 Pass

    @@ -90,8 +90,8 @@
    Test msg
    -09.27.2024 10:13:26 AM -09.27.2024 10:13:26 AM +09.28.2024 4:50:15 PM +09.28.2024 4:50:15 PM 00:00:00:000 · #test-id=1 @@ -115,13 +115,13 @@

    Started

    -

    Sep 27, 2024 10:13:21 AM

    +

    Sep 28, 2024 04:50:12 PM

    Ended

    -

    Sep 27, 2024 10:13:26 AM

    +

    Sep 28, 2024 04:50:15 PM

    @@ -182,7 +182,7 @@ var timeline = { NameValue -Test Done By: +Tester ID: Sami diff --git a/src/main/java/zacksolutions/base/Initialization.java b/src/main/java/zacksolutions/base/Initialization.java index a0f19cd..4bc86a0 100644 --- a/src/main/java/zacksolutions/base/Initialization.java +++ b/src/main/java/zacksolutions/base/Initialization.java @@ -1,4 +1,5 @@ package zacksolutions.base; + import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; @@ -7,23 +8,24 @@ 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.chrome.ChromeOptions; import org.openqa.selenium.firefox.FirefoxDriver; public class Initialization { - //let's set up our variables + // let's set up our variables 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) { @@ -34,7 +36,7 @@ public class Initialization { } public void BrowserInit() { - //our EXTENTREPORTS SETUP! + // our EXTENTREPORTS SETUP! String path = System.getProperty("user.dir") + "/reports/index.html"; ExtentSparkReporter spark = new ExtentSparkReporter(path); @@ -44,20 +46,25 @@ public class Initialization { extent.attachReporter(spark); extent.setSystemInfo("Tester ID: ", "Sami"); - //conditioning our WebDriver with an if statement + // conditioning our WebDriver with an if statement String browsername = prop.getProperty("browserC"); - //launching FireFox + // launching FireFox if (browsername.equalsIgnoreCase("firefox")) { - System.setProperty("web-driver.gecko.driver","user.dir" + "/drivers/geckodriver"); - driver = new FirefoxDriver(); + // System.setProperty("web-driver.gecko.driver","user.dir" + + // "/drivers/geckodriver"); + // driver = new FirefoxDriver(); driver.get(prop.getProperty("url")); } - //launching Chrome + // launching Chrome if (browsername.equalsIgnoreCase("chrome")) { - System.setProperty("web-driver.gecko.driver", "user.dir" + "/drivers/chromedriver"); - driver = new ChromeDriver(); + // 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(); diff --git a/src/test/java/zacksolutions/HomePageTest.java b/src/test/java/zacksolutions/HomePageTest.java index 489b718..888b562 100644 --- a/src/test/java/zacksolutions/HomePageTest.java +++ b/src/test/java/zacksolutions/HomePageTest.java @@ -7,27 +7,30 @@ import org.testng.annotations.Test; import zacksolutions.base.Initialization; import zacksolutions.pages.HomePage; - public class HomePageTest extends Initialization { - HomePage homePage; - public HomePageTest(){ - super(); - } - @BeforeTest - public void setUp(){ - BrowserInit(); - homePage = new HomePage(); - } - @Test - public void TextTest() throws InterruptedException { - HomePage hp = new HomePage(); - hp.insertText(); - hp.textConfirmation(); - Assert.assertEquals(hp.textConfirmation(), "4 8 15 16 23 42"); - } - @AfterTest - public void tearDown(){ - driver.close(); - } + HomePage homePage; + + public HomePageTest() { + super(); + } + + @BeforeTest + public void setUp() { + BrowserInit(); + homePage = new HomePage(); + } + + @Test + public void TextTest() throws InterruptedException { + HomePage hp = new HomePage(); + hp.insertText(); + hp.textConfirmation(); + Assert.assertEquals(hp.textConfirmation(), "4 8 15 16 23 42"); + } + + @AfterTest + public void tearDown() { + driver.close(); + } }