Selenium Grid 2 parallel Test Case execution - java

I want to use Selenium Grid for my Testing in that I have successfully launched the Grid and Launched the HUB and NODE .. i also did set my RemoteWebdriver Capability perfectly .. but when I try run the test, all the browers is being opened perfectly but the problem i'm facing is that some browser stop in the middle like
some open the webpage and stops
some enters the login page and stops
some loges in and stop and giving me the ERROR as
Element Not Found
Unable to Click Element
Element not found in the cache
Can anyone please help me ...
Thanks in Advance.
My sample Code is
public class GmailMail{
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
#BeforeClass
public void setup(String browser) throws InterruptedException, IOException {
DesiredCapabilities capability=null;
if(browser.equalsIgnoreCase("googlechrome")){
/*ChromeDriverService chromeDriverService = new ChromeDriverService.Builder()
.usingDriverExecutable(
new File("D:\\downloaded setup\\zip file\\chromedriver_win_26.0.1383.0\\chromedriver.exe"))
.usingAnyFreePort().build();
chromeDriverService.start();
driver = new ChromeDriver(chromeDriverService);*/
System.out.println("googlechrome");
capability= DesiredCapabilities.chrome();
capability.setBrowserName("chrome");
capability.setPlatform(org.openqa.selenium.Platform.WINDOWS);
//capability.setVersion("");
System.setProperty("webdriver.chrome.driver",
"D:\\downloaded setup\\zip file\\chromedriver_win_26.0.1383.0\\chromedriver.exe");
driver = new ChromeDriver();
}
if(browser.equalsIgnoreCase("firefox")){
System.out.println("firefox");
capability= DesiredCapabilities.firefox();
capability.setBrowserName("firefox");
capability.setPlatform(org.openqa.selenium.Platform.ANY);
//capability.setVersion("");
}
if(browser.equalsIgnoreCase("iexplore")){
System.out.println("iexplore");
capability= DesiredCapabilities.internetExplorer();
capability.setBrowserName("iexplore");
capability.setPlatform(org.openqa.selenium.Platform.WINDOWS);
//capability.setVersion("");*/
System.setProperty("webdriver.ie.driver", "D:\\downloaded setup\\zip file\\IEDriverServer_Win32_2.29.0\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
}
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
driver.navigate().to(baseUrl);
long ss = Thread.currentThread().getId();
System.out.println("ss: "+ss);
}
#Test
public void testUntitled() throws Exception {
driver.get(baseUrl + "/ServiceLogin?service=mail&passive=true&rm=false&continue=http://mail.google.com/mail/&scc=1&ltmpl=default&ltmplcache=2");
driver.findElement(By.id("Email")).clear();
driver.findElement(By.id("Email")).sendKeys("YourUserName");
driver.findElement(By.id("Passwd")).clear();
driver.findElement(By.id("Passwd")).sendKeys("YourPassowrd");
driver.findElement(By.id("signIn")).click();
}
#AfterClass
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alert.getText();
} finally {
acceptNextAlert = true;
}
}
}
and my Testng.xml is
<suite name="Same TestCases on Different Browser" verbose="3" parallel="tests" thread-count="2">
<test name="Run on Internet Explorer">
<parameter name="browser" value="firefox"/>
<classes>
<class name="TestPAck1.GmailMail"/>
</classes>
</test>
<test name="Run on Internet Explorer1">
<classes>
<parameter name="browser" value="googlechrome"/>
<class name="TestPAck1.GmailMail"/>
</classes>
</test>
</suite>

at first glance this seems to be a sync issue. If you could share the appropriate section of your code, it might be easier to identify the issue.

Related

Test framework architecture using Selenium WebDriver and TestNG

guys. I trying to solve a problem with parallel running using RC Webdriver and TestNG, but unfortunately, I can't find solution last few hours. Maby you will see the code, and show me what, I actually doing wrong.
Goal:
Create architecture using RC WebDriver and TestNG, with an ability to run tests on a remote machine.
Main settings class is Sut:
private RemoteWebDriver driver = null;
#BeforeClass
public WebDriver getWebDriver() {
DesiredCapabilities dc = new DesiredCapabilities();
FirefoxProfile fp = new FirefoxProfile();
dc.setCapability(FirefoxDriver.PROFILE, fp);
dc.setBrowserName(DesiredCapabilities.firefox().getBrowserName());
try {
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), dc);
} catch (MalformedURLException e) {
e.printStackTrace();
}
return driver;
}
#AfterClass
public void tearDown() {
driver.quit();
}
In this class we have two methods: getWebDriver() - for setup our remote webdriver, and tearDown() - for close web-page, when a test will be complete.
Class BaseStep:
private static ThreadLocal<Sut> sut = new ThreadLocal<Sut>();
public static Sut getSut() {
Sut currentSut = sut.get();
if (currentSut == null) {
currentSut = new Sut();
}
return currentSut;
}
It's an additional layer, which create 'new state for each new thread'.
Few page objects:
public class FacebookPage {
public void testLink() {
getSut().getWebDriver().get("http://facebook.com");
}
}
public class GooglePage {
public void testLink() {
getSut().getWebDriver().get("http://google.com");
}
}
And scenarious classes:
public class VerifyGooglePage {
GooglePage googlePage = new GooglePage();
#Test
public void verifyGoogleMainPage() {
googlePage.testLink();
}
}
public class VerifyFacebookPage {
Facebook facebookPage = new Facebook();
#Test
public void verifyFacebookeMainPage() {
facebookPage.testLink();
}
}
And my and testNG.xml file for running
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="1" name="Suite" parallel="tests">
<test name="FirstTest">
<classes>
<class name="scenarious.VerifyGooglePage"/>
</classes>
</test> <!-- Test -->
<test name="SecondTest">
<classes>
<class name="scenarious.VerifyFacebookPage"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
The problems is: When test complete, browser is not closed.
the Picture
I watched a lot of tutorials and articles in internet about it, but in no-one I cant found solution for my case. Could you please help me to find what I doing wrong.

Parellel testing with TestNG - Tests only run on one browser

I have created a test suite using
DataProvider
DataFactory
and my TestNG file is sending browser details as parameters. In testNG XML I'm calling my data factory class. I'm also using browsestack for testing (although I doubt this has anything to do with the problem I"m having)
Tests run without any issues when I don't add parrellel="true" to testng file.
I have a feeling it has something to do with same driver being used by each browser, but I'm out of depth to solve this at the moment.
Any guidance is appreciated.
Here's the code.
TestNG.XML
<suite name="Suite" verbose="1" parallel="tests">
<!-- Test with Chrome -->
<test name="ChromeTest" group-by-instances="true">
<parameter name="browser" value="Chrome"></parameter>
<parameter name="browserVersion" value="47"></parameter>
<parameter name="platform" value="Windows"></parameter>
<parameter name="platformVersion" value="7"></parameter>
<classes>
<class name="Resources.TestFactory"/>
</classes>
</test>
<!-- Test with Firefox -->
<test name="FirefoxTest" group-by-instances="true">
<parameter name="browser" value="Firefox"></parameter>
<parameter name="browserVersion" value="43"></parameter>
<parameter name="platform" value="Windows"></parameter>
<parameter name="platformVersion" value="7"></parameter>
<classes>
<class name="Resources.TestFactory"/>
</classes>
</test>
</suite>
Data Factory Class
public class TestFactory {
#Factory(dataProvider = "LoginCredentials", dataProviderClass=TestData.class)
public Object[] createInstances(int testNo, String userName, String password) {
Object[] result = new Object[1];
int i=0;
System.out.println("Inside LoginCredentials Factory - " + userName + "---" + password);
if(testNo==1){
result[i] = new Test_BookingEngine_Login(userName, password);
i++;
System.out.println("Object Array : " + Arrays.deepToString(result));
}
else if(testNo==2){
result[i] = new Test_BookingManagement_OpenBooking(userName);
i++;
System.out.println("Object Array : " + Arrays.deepToString(result));
}
System.out.println("outside for");
return result;
}
}
Suite - Driver Initialization
#BeforeTest
#Parameters(value ={"browser", "browserVersion", "platform", "platformVersion"})
public void initBrowser(String browser, String browserVersion, String platform, String platformVersion) throws Exception{
//Initializing browser in cloud
cloudCaps = new DesiredCapabilities();
cloudCaps.setCapability("browser", browser);
cloudCaps.setCapability("browser_version", browserVersion);
cloudCaps.setCapability("os", platform);
cloudCaps.setCapability("os_version", platformVersion);
cloudCaps.setCapability("browserstack.debug", "true");
cloudCaps.setCapability("browserstack.local", "true");
driver = new RemoteWebDriver(new URL(URL), cloudCaps);
}
Sample Test
public Test_BookingEngine_Login(String userName, String password) {
this.userName = userName;
this.password = password;
}
#Test (groups = {"Login"})
public void testHomePageAppearCorrect() throws InterruptedException{
//Starting test and assigning test category
test = logger.startTest("Login to Temptation", "<b>Successful user login or Pop up advising incorrect login details</b><br/><br/>" + browserInfo)
.assignCategory("Regression", "Booking Engine")
.assignAuthor("Dinesh Cooray");
System.out.println("Inside login test");
System.out.println("Browser inside login test : ");
driver.get("http://dev-thor2.tempoholidays.com/");
test.log(LogStatus.INFO, "HTML", "Navigated to http://dev-thor2.tempoholidays.com/");
//create Login Page object
objLogin = new BookingEngine_Login(driver);
//login to application
objLogin.loginToTemptationBookingEngine(userName, password, test);
//check if alert advising username or password is is incorrect
try {
//incorrect login details, user should not allow login
if(driver.switchTo().alert().getText().toLowerCase().contains("user name or password is wrong")){
test.log(LogStatus.INFO, "HTML", "<b>Popup - </b>" + driver.switchTo().alert().getText());
driver.switchTo().alert().accept();
Assert.assertTrue(true);
}
}
I am guessing RemoteWebDriver driver; would be a line you added at the class level.
What is happening is that you have already declared the variable at class level. i.e. memory is already allocated to it.When you do something like this driver = new RemoteWebDriver(new URL(URL), cloudCaps); you are just setting and resetting the values of the same variable in every #BeforeTest
What you need to do is create a factory that will return an instance of RemoteWebDriver based on a parameter you pass to it.Essentially the factory will create a new object and return only if an existing object doesn't exist.
Declare and initialise the driver (from factory) in your #Test Methods
Sample code for the factory would be something like
static RemoteWebDriver firefoxDriver;
static RemoteWebDriver someOtherDriver;
static synchronized RemoteWebDriver getDriver(String browser, String browserVersion, String platform, String platformVersion)
{
if (browser == 'firefox')
{
if (firefoxDriver == null)
{
DesiredCapabilities cloudCaps = new DesiredCapabilities();
cloudCaps.setCapability("browser", browser);
cloudCaps.setCapability("browser_version", browserVersion);
cloudCaps.setCapability("os", platform);
cloudCaps.setCapability("os_version", platformVersion);
cloudCaps.setCapability("browserstack.debug", "true");
cloudCaps.setCapability("browserstack.local", "true");
firefoxDriver = new RemoteWebDriver(new URL(URL),cloudCaps);
}
}
else
{
if (someOtherDriver == null)
{
DesiredCapabilities cloudCaps = new DesiredCapabilities();
cloudCaps.setCapability("browser", browser);
cloudCaps.setCapability("browser_version", browserVersion);
cloudCaps.setCapability("os", platform);
cloudCaps.setCapability("os_version", platformVersion);
cloudCaps.setCapability("browserstack.debug", "true");
cloudCaps.setCapability("browserstack.local", "true");
someOtherDriver = new RemoteWebDriver(new URL(URL),cloudCaps);
}
return someOtherDriver;
}
}
}

Webdriver object gets overwritten when tests are run in parallel

I'm writing Java based selenium-web-driver tests to run a parallel cross browser test using testng .
I have set the tests to run parallel on my xml file.The file looks like this :
<suite name="TestSuite" thread-count="2" parallel="tests" >
<test name="ChromeTest">
<parameter name="browser" value="Chrome" />
<classes>
<class name="test.login"/>
<class name="test.main"/>
<class name="test.logout"/>
</classes>
</test>
<test name="FirefoxTest">
<parameter name="browser" value="Firefox" />
<classes>
<class name="test.login"/>
<class name="test.main"/>
<class name="test.logout"/>
</classes>
</test>
But when i run test, both browser instances gets opened (Chrome opens first and starts execution and after a delay Firefox is opened).
In that case , the driver object gets overwritten by Firefox driver and chrome stops execution.Tests continue execution on Firefox and
gets completed successfully.
The structure of the project is like this :
Created a driverbase.class to load driver corresponding to browser which has my #Beforesuite.
Crteated individual classes for pages.(Eg: login.class , main.class etc) which has only #Test method and have extended driverbase class to get driver.
Test are run suceessfully when i set parallel to none on xml file
<suite name="TestSuite" thread-count="2" parallel="none" >
How can i overcome this issue? How to run tests in parallel without this issue?
The driverbase class is like this :
public class driverbase {
private String baseUrl;
private String nodeUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
public static WebDriver driver = null;
/**
* This function will execute before each Test tag in testng.xml
* #param browser
* #throws Exception
*/
#BeforeSuite
#Parameters("browser")
public WebDriver setup(String browser) throws Exception{
//Check if parameter passed from TestNG is 'firefox'
if(browser.equalsIgnoreCase("firefox")){
System.out.println("Browser : "+browser);
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(true);
//create firefox instance
driver = new FirefoxDriver(profile);
}
//Check if parameter passed as 'chrome'
else if(browser.equalsIgnoreCase("chrome")){
System.out.println("Browser : "+browser);
//set path to chromedriver.exe You may need to download it from http://code.google.com/p/selenium/wiki/ChromeDriver
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--test-type");
//create chrome instance
driver = new ChromeDriver(options);
}
else{
//If no browser passed throw exception
System.out.println("Browser is incorrect");
throw new Exception("Browser is not correct");
}
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();
return driver;
}
Thanks for the help :)
#BeforeSuite methods are not supposed to return something. => replace by void
Your testng has 2 differents tests, but #BeforeSuite will always be run once by suite what your comment shows you doesn't expect it. => replace by #BeforeTest
When you run in //, 2 threads are settings the driver value (one with firefox, one with chrome) which explains your problem.
You can try something like:
public class driverbase {
private String baseUrl;
private String nodeUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
public WebDriver driver;
#BeforeTest
#Parameters("browser")
public void setup(String browser) throws Exception {
if(browser.equalsIgnoreCase("firefox")) {
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(true);
driver = new FirefoxDriver(profile);
} else if(browser.equalsIgnoreCase("chrome")) {
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--test-type");
driver = new ChromeDriver(options);
} else {
throw new Exception("Browser is not correct");
}
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();
}
You should have a look on http://fluentlenium.org/ too.
To sure that same instance of webdriver won't be assigned to multiple tests. The method where driver instances are being created should be synchronized. This should solve the issue.
public synchronized void setup(String browser) throws Exception {
if(browser.equalsIgnoreCase("firefox")) {
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(true);
driver = new FirefoxDriver(profile);
} else if(browser.equalsIgnoreCase("chrome")) {
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--test-type");
driver = new ChromeDriver(options);
} else {
throw new Exception("Browser is not correct");
}
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();
}

Parameterized Selenium Tests in Parallel with TestNG

First of all, sorry for my english, it's not so perfect :)
So I'm facing with the following problem: I'm trying to run parallel tests in different browsers using Selenium Grid and TestNg and I pass the parameters in the #BeforeTest method. My problem is that when every test get initialized, it seems that they will use the last test's parameters. So in this example when I run the test, it will open two Chrome, instead of one Firefox and one Chrome.
(The browser.getDriver() method returns a RemoteWebDriver)
TestNG.xml:
<suite thread-count="2" verbose="10" name="testSuite" parallel="tests">
<test name="nameOfTheTestFirefox">
<parameter name="platform" value="windows"/>
<parameter name="browserVersion" value="32"/>
<parameter name="browserName" value="firefox"/>
<classes>
<class name="example.test.login.LoginOverlayTest"/>
</classes>
</test> <!-- nameOfTheTestFirefox -->
<test name="nameOfTheTestChrome">
<parameter name="platform" value="windows"/>
<parameter name="browserVersion" value="38"/>
<parameter name="browserName" value="chrome"/>
<classes>
<class name="example.test.login.LoginOverlayTest"/>
</classes>
</test> <!-- nameOfTheTestChrome -->
</suite> <!-- testSuite -->
The AbstractTest class:
public class SeleniumTest {
private static List<WebDriver> webDriverPool = Collections.synchronizedList(new ArrayList<WebDriver>());
private static ThreadLocal<WebDriver> driverThread;
public static BrowserSetup browser;
#Parameters({ "browserName", "browserVersion", "platform"})
#BeforeTest()
public static void beforeTest(String browserName, #Optional("none") String browserVersion, String platform) throws WrongBrowserException, WrongPlatformException {
final BrowserSetup browser = new BrowserSetup(browserName, browserVersion, platform);
driverThread = new ThreadLocal<WebDriver>() {
#Override
protected WebDriver initialValue() {
final WebDriver webDriver = browser.getDriver();
webDriverPool.add(webDriver);
return webDriver;
}
};
}
public static WebDriver getDriver() {
return driverThread.get();
}
#AfterTest
public static void afterTest() {
for (WebDriver driver : webDriverPool) {
driver.quit();
}
}
}
And my example #Tests:
#Test
public void test1() throws InterruptedException {
WebDriver driver = getDriver();
System.out.println("START: test1");
driver.get("http://google.com");
Thread.sleep(5000);
System.out.println("END: test1, title: " + driver.getTitle());
}
#Test
public void test2() throws InterruptedException {
WebDriver driver = getDriver();
System.out.println("START: test2");
driver.get("http://amazon.com");
Thread.sleep(5000);
System.out.println("END: test2, title: " + driver.getTitle());
}
#Test
public void test3() throws InterruptedException {
WebDriver driver = getDriver();
System.out.println("START: test3");
driver.get("http://stackoverflow.com");
Thread.sleep(5000);
System.out.println("END: test3, title: " + driver.getTitle());
}
So my question is how can I run the tests in parallel with the given parameters in separate threads?
Thanks in advance!
Peter
Don't make the fields static.
private static List<WebDriver> webDriverPool = Collections.synchronizedList(new ArrayList<WebDriver>());
private static ThreadLocal<WebDriver> driverThread;
public static BrowserSetup browser;
beforeTest() and afterTest() shouldn't be static if you want to run it in parallel, or make it synchronized to have it thread safe. Also, you do not use declared variable:
public static BrowserSetup browser;
at all, or you missed something there since you also have:
final BrowserSetup browser = new BrowserSetup(browserName, browserVersion, platform);
inside beforeTest(...)

testNG parallel execution not working

I am trying to run following test in parallel for two browsers using testNG, while running both the browsers are getting launched with the URL, but the complete test execution is happening for only one browser.
Here is my Test Suite class
#Test (groups = {"Enable"})
#SuppressWarnings("unused")
public class EETestSuite_01 extends ApplicationFunctions{
String URL = Globals.GC_EMPTY;
#BeforeTest
#Parameters("browser")
public void loadTest(String browser) throws IOException{
InitializeTestEnv("EE|BizApp");
if(browser.equalsIgnoreCase("Firefox"))
GetBrowser("Firefox");
else if(browser.equalsIgnoreCase("Chrome")){
GetBrowser("Chrome");
}
}
#AfterMethod
public void cleartest() throws InterruptedException{
driver.close();
driver.quit();
driver = null;
}
public void TC001_Phone_First_Acquisition_Journey_PAYM() throws InterruptedException{
URL = EnvDetail.get(Globals.GC_HOME_PAGE);
Map<String,String> TDChoosePlan = null;
TDChoosePlan = getData(appName+Globals.GC_TEST_DATA_SHEET,"ChoosePlan",1);
try{
launchApp(URL);
//driver.navigate().to("javascript:document.getElementById('overridelink').click()");
EEHomePage homePage = PageFactory.initElements(driver, EEHomePage.class);
EEShopPage shopPage = homePage.GetToShopPage();
EEPhoneMatrixPage phonePage = shopPage.GetToPhoneMatrixPage();
EEChoosePlanPage planPage = phonePage.ChoosePhone("NokiaLumia1020"); // Implement select phone
EEAddonsPage addonPage = planPage.SelectPhonesPlan(TDChoosePlan);
EEBasket basketPage = addonPage.GoToBasketPage();
EESecureCheckOut secureChkOutPage = basketPage.GoToSecureCheckOutPage();
secureChkOutPage.ChooseNonExistingCustomer();
EEConfirmation confPage = secureChkOutPage.FillUserRegisterForm(2);
}catch(Exception e){
e.printStackTrace();
}
}
}
My XML looks like this
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name = "EEAutomationTestSuite" verbose="2" parallel = "tests" thread-count="100">
<test name="PAYM Acquisition in Chrome">
<parameter name="browser" value="Firefox"></parameter>
<classes>
<class name="com.testsuite.EETestSuite_01">
</class>
</classes>
</test>
<test name="PAYM Acquisition in FF">
<parameter name="browser" value="Firefox"></parameter>
<classes>
<class name="com.testsuite.EETestSuite_01">
</class>
</classes>
</test>
</suite>
And my code for the Home page is this
*/ public EEShopPage GetToShopPage() throws InterruptedException{
// longWait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(OR.getProperty("wblShopHeader"))));
lblShopHeader = driver.findElement(By.cssSelector(OR.getProperty("wblShopHeader")));
Actions builder = new Actions(driver);
Actions hoverOverRegistrar = builder.moveToElement(lblShopHeader);
hoverOverRegistrar.perform();Thread.sleep(10000);
lnkStartShopping = driver.findElement(By.cssSelector(OR.getProperty("lnkStartShopping")));
mediumWait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(OR.getProperty("lnkStartShopping"))));
lnkStartShopping.click();
return PageFactory.initElements(driver,EEShopPage.class );
}
}
Here is the driver
public static void GetBrowser(String browser){
try{
if (browser.equalsIgnoreCase("firefox")) {
// FirefoxProfile firefoxProfile = new FirefoxProfile();
// File pathToBinary = new File(Globals.GC_FIREFOX_BIN_PATH);
// FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
//firefoxProfile.setPreference("webdriver.load.strategy","unstable");
driver = new FirefoxDriver();
} else if (browser.equalsIgnoreCase("iexplorer")){
System.setProperty("webdriver.ie.driver", System.getProperty("user.dir") +
"//resource//drivers//IEDriverServer.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
driver = new InternetExplorerDriver(capabilities);
} else if (browser.equalsIgnoreCase("chrome")){
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") +
"//resource//drivers//chromedriver.exe");
I am just guessing that there is a hover action in the home page, and for one browser it works fine but for the other nothing happens.... is it due focus issue ??
Please let me know how to solve this with an example
I cannot make it out from your code, which constructor you are using for your page Object EEHomePage.
Because, if you are using default constructor then your PageFactory will not be able to initialize your web elements unless they are defined by #FindBy annotation,
PageFactory takes webDriver and Object class as arguments and internally initializes that Object class with provided webDriver.This can be achieved by two ways as below :
1) either define your webElements in your pageObjects using #FindBy annotations as follow :
#FindBy(css=//your locator value here)
private WebElement lblShopHeader;
OR
2) define constructor and initialize your pageobject webdriver by PageFactory provided webdriver as follow :
EEHomeShop(WebDriver driver){
this.driver=driver;
}

Categories

Resources