commit 74fd6a9f24e287a4bc2f9c9e47ed7ba051a486b9 Author: dadgam3er Date: Thu Sep 26 13:00:23 2024 -0400 Zen fix: 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e122dea --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/drivers/chromedriver b/drivers/chromedriver new file mode 100755 index 0000000..47350a7 Binary files /dev/null and b/drivers/chromedriver differ diff --git a/drivers/geckodriver b/drivers/geckodriver new file mode 100755 index 0000000..c525beb Binary files /dev/null and b/drivers/geckodriver differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..21bf159 --- /dev/null +++ b/pom.xml @@ -0,0 +1,68 @@ + + 4.0.0 + + zacksolutions + Zenful + 1.0-SNAPSHOT + jar + + Zenful + http://maven.apache.org + + 8 + 8 + UTF-8 + + + + com.aventstack + extentreports + 5.1.2 + + + + org.testng + testng + 7.10.2 + compile + + + + org.seleniumhq.selenium + selenium-java + 4.25.0 + + + + org.apache.poi + poi + 5.3.0 + + + + org.apache.poi + poi-ooxml + 5.3.0 + + + + org.apache.poi + poi-scratchpad + 5.3.0 + + + + org.apache.poi + poi-ooxml-schemas + 4.1.2 + + + + org.apache.logging.log4j + log4j-core + 2.24.0 + + + + diff --git a/src/main/java/zacksolutions/base/Initialization.java b/src/main/java/zacksolutions/base/Initialization.java new file mode 100644 index 0000000..0726784 --- /dev/null +++ b/src/main/java/zacksolutions/base/Initialization.java @@ -0,0 +1,40 @@ +package zacksolutions.base; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Properties; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxDriver; + +public class Initialization { + public static WebDriver driver; + public static Properties prop; + + public Initialization() { + + try { + + prop = new Properties(); + FileInputStream fis = new FileInputStream("/home/ilyes/SeleniumPractice/Zenful/src/main/java/zacksolutions/config/config.properties"); + prop.load(fis); + + } catch (FileNotFoundException e) { + // TODO: handle exception + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + public void BrowserInit() { + String browsername = prop.getProperty("browserF"); + if (browsername.equalsIgnoreCase("firefox")) { + System.setProperty("web-driver.gecko.driver","/home/ilyes/SeleniumPractice/Zenful/drivers/geckodriver"); + driver = new FirefoxDriver(); + driver.get(prop.getProperty("url")); + } + } +} diff --git a/src/main/java/zacksolutions/config/config.properties b/src/main/java/zacksolutions/config/config.properties new file mode 100644 index 0000000..50d65db --- /dev/null +++ b/src/main/java/zacksolutions/config/config.properties @@ -0,0 +1,5 @@ +url=https://zenful.cloud/ + +browserC= chrome +browserF= firefox + diff --git a/src/main/java/zacksolutions/pages/HomePage.java b/src/main/java/zacksolutions/pages/HomePage.java new file mode 100644 index 0000000..25bf642 --- /dev/null +++ b/src/main/java/zacksolutions/pages/HomePage.java @@ -0,0 +1,31 @@ +package zacksolutions.pages; + +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.PageFactory; +import zacksolutions.base.Initialization; + +public class HomePage extends Initialization { + @FindBy(id="message") + WebElement message; + + @FindBy(css="button[type='submit']") + WebElement button; + + @FindBy(css="tbody tr:nth-child(1) td:nth-child(1)") + WebElement ConfirmText; + + //Initialization + public HomePage(){ + PageFactory.initElements(driver, this); + } + + //Actions + public void insertText() throws InterruptedException { + message.sendKeys("4 8 15 16 23 42"); + button.click(); + } + public String textConfirmation(){ + return ConfirmText.getText(); + } +} diff --git a/src/test/java/zacksolutions/HomePageTest.java b/src/test/java/zacksolutions/HomePageTest.java new file mode 100644 index 0000000..91be350 --- /dev/null +++ b/src/test/java/zacksolutions/HomePageTest.java @@ -0,0 +1,31 @@ +package zacksolutions; + +import org.testng.Assert; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +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(); + } +}