forked from Zakaria/ZenProject
Zen fix: 1
This commit is contained in:
@@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
url=https://zenful.cloud/
|
||||
|
||||
browserC= chrome
|
||||
browserF= firefox
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user