ackage selenium.src.com.ofb.supportClasses;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.events.EventFiringWebDriver;
import org.openqa.selenium.support.events.WebDriverEventListener;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
public class OfbTestSet{
private WebDriver webDriver;
private String testUrl, loginID, password;
@BeforeMethod(alwaysRun = true)
@Parameters({"browser", "testUrl", "loginID", "password"})
public void setUp(@Optional ("") String browser,
@Optional ("") String testUrl,
@Optional ("") String loginID,
@Optional ("") String password) throws Exception{
if (browser.contentEquals(""))
browser = ReadProperty.commonValueProps.getProperty("browser");
if (testUrl.contentEquals(""))
testUrl = ReadProperty.commonValueProps.getProperty("testUrl");
if (loginID.contentEquals(""))
loginID = ReadProperty.commonValueProps.getProperty("LoginID");
if (password.contentEquals(""))
password = ReadProperty.commonValueProps.getProperty("Password");
this.testUrl = testUrl; this.loginID = loginID; this.password = password;
if (browser.contentEquals("firefox"))
{
//FirefoxProfile ofbFF = new FirefoxProfile(new File("OfbFirefoxProfile/data"));
//ofbFF.setAcceptUntrustedCertificates(false);
//ofbFF.setAssumeUntrustedCertificateIssuer(false);
//ofbFF.setPreference("network.dns.disableIPv6", true);
//ofbFF.setEnableNativeEvents(false);
WebDriverEventListener eventListener = new CustomEventListener();
webDriver = new EventFiringWebDriver(new FirefoxDriver()).register(eventListener);
}
if (browser.contentEquals("iexplorer"))
{
WebDriverEventListener eventListener = new CustomEventListener();
webDriver = new EventFiringWebDriver(new InternetExplorerDriver()).register(eventListener);
}
webDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
webDriver.get(testUrl);
//To maximize the browser window
WebDriverBackedSelenium selenium = new WebDriverBackedSelenium(webDriver, "");
selenium.windowMaximize();
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception {
webDriver.quit();
}
public WebDriver getWebDriver() {
return webDriver;
}
public String getTestUrl(){
return testUrl;
}
public String getLoginID(){
return loginID;
}
public String getPassword(){
return password;
}
}
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.events.EventFiringWebDriver;
import org.openqa.selenium.support.events.WebDriverEventListener;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
public class OfbTestSet{
private WebDriver webDriver;
private String testUrl, loginID, password;
@BeforeMethod(alwaysRun = true)
@Parameters({"browser", "testUrl", "loginID", "password"})
public void setUp(@Optional ("") String browser,
@Optional ("") String testUrl,
@Optional ("") String loginID,
@Optional ("") String password) throws Exception{
if (browser.contentEquals(""))
browser = ReadProperty.commonValueProps.getProperty("browser");
if (testUrl.contentEquals(""))
testUrl = ReadProperty.commonValueProps.getProperty("testUrl");
if (loginID.contentEquals(""))
loginID = ReadProperty.commonValueProps.getProperty("LoginID");
if (password.contentEquals(""))
password = ReadProperty.commonValueProps.getProperty("Password");
this.testUrl = testUrl; this.loginID = loginID; this.password = password;
if (browser.contentEquals("firefox"))
{
//FirefoxProfile ofbFF = new FirefoxProfile(new File("OfbFirefoxProfile/data"));
//ofbFF.setAcceptUntrustedCertificates(false);
//ofbFF.setAssumeUntrustedCertificateIssuer(false);
//ofbFF.setPreference("network.dns.disableIPv6", true);
//ofbFF.setEnableNativeEvents(false);
WebDriverEventListener eventListener = new CustomEventListener();
webDriver = new EventFiringWebDriver(new FirefoxDriver()).register(eventListener);
}
if (browser.contentEquals("iexplorer"))
{
WebDriverEventListener eventListener = new CustomEventListener();
webDriver = new EventFiringWebDriver(new InternetExplorerDriver()).register(eventListener);
}
webDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
webDriver.get(testUrl);
//To maximize the browser window
WebDriverBackedSelenium selenium = new WebDriverBackedSelenium(webDriver, "");
selenium.windowMaximize();
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception {
webDriver.quit();
}
public WebDriver getWebDriver() {
return webDriver;
}
public String getTestUrl(){
return testUrl;
}
public String getLoginID(){
return loginID;
}
public String getPassword(){
return password;
}
}
Great post I must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more. 4 ps of marketing
ReplyDelete