Not Able to Run Serenity BDD Test Cases in IE & Chrome Browser

2,653 views
Skip to first unread message

Netra Shivakumar

unread,
Dec 9, 2015, 6:23:23 PM12/9/15
to Serenity BDD Users Group


I tried to run Serenity BDD test in chrome or IE using following two commands below at a time, for some reason I am not successful, I followed many sites advice or instructions, nothing seems to worked for me on this, I have attached my fail trace file with this, I would appreciate any of you suggest how to run successfully serenity BDD tests in IE and Chrome.  I have attached copy of trace fail file.

mvn verify -Dwebdriver.driver=iexplorer

 

mvn verify -Dwebdriver.driver=iexplorer –Dwebdriver.ie.driver=./IEDriverServer.exe.

 

Thank You
Netra

FailTraceIE.docx

Netra Shivakumar

unread,
Dec 15, 2015, 5:46:12 PM12/15/15
to Serenity BDD Users Group
I was able to use Selenium grid  to run serenity test case but still I have a glitch, please see my sample of my test case below, when I run this, it starts session at node with IE, it simply says "this is the initial start stage for the WebDriver.server" 7 no test steps are executed but where as at hub it runs all test cases in firefox successfully.  Here my question is why at  node did not  run all test steps, & how do I make all steps run at node in IE.  I appreciate any help on this.

**************************************

package com.features.NewTry;

import org.junit.Before;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.openqa.selenium.Platform;

import org.openqa.selenium.WebDriver;

import com.steps.NewTryTwoSteps;

import net.serenitybdd.junit.runners.SerenityRunner;

import net.thucydides.core.annotations.Managed;

import net.thucydides.core.annotations.Steps;

import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.MalformedURLException;

import java.net.URL;

import org.openqa.selenium.remote.RemoteWebDriver;

@RunWith(SerenityRunner.class)

public class NewTryTwoTest {

@Managed(uniqueSession = true)

// @Managed(driver = "chrome")

// public WebDriver webdriver;

public WebDriver driver = null;

// public ChromeDriver webdriver;

String BaseURL;

@Steps

public NewTryTwoSteps NewEndUser;

/* @Before

public void setup() {

// System.setProperty("webdriver.iexplorer.driver", "C:/opt/IEDriverServer.exe");

System.setProperty("webdriver.iexplorer.driver", "C:/opt.IEDriverServer.exe");

} */

@Before

public void setup() throws MalformedURLException {

BaseURL="http://www.google.com";

// System.setProperty("webdriver.ie.driver", "C:/opt/IEDriverServer");

System.setProperty("webdriver.iexplorer.driver", "C:/opt/IEDriverServer");

DesiredCapabilities capability = DesiredCapabilities.internetExplorer();

capability.setBrowserName("internet explorer");

capability.setVersion("11.0.9600.18124");

// capability.setBrowserName("firefox");

capability.setPlatform(Platform.WINDOWS);

// capability.setPlatform(Platform.VISTA);

driver = new RemoteWebDriver (new URL("http://172.26.98.175:5555/wd/hub"), capability);

// driver.get(BaseURL);

}

// WebDriver webdriver = new ChromeDriver();

@Test

public void Test_One() {

// Navigate to Home Page

NewEndUser.Navigate_To_home_page();

NewEndUser.clickLink();

}

@Test

public void Test_Two() {

// Navigate to Home Page

NewEndUser.Navigate_To_home_page();

NewEndUser.clickLink();

}

}

*********************************************

Harry King

unread,
Dec 17, 2015, 4:10:51 AM12/17/15
to Serenity BDD Users Group
Internet Explorer can be a bit tricky to get started with, especially IE11.  Have you setup IE as recommended by Selenium?

Netra Shivakumar

unread,
Dec 18, 2015, 10:25:31 AM12/18/15
to Serenity BDD Users Group
Thank You, Yes I have set it correctly, here is my issue refer below test code,

When I run below test as JUNIT in eclipse, it opens separate session for each test at node in IE correctly & also opens separate sessions for each test at hub in FF.

 In node,  for each test it only  opens Google which is due to line#53 driver.get(BaseURL) embedded in @Before, here my issue or my question is  is why this IE session in node machine does not run all steps  in each test.

where as at hub all steps in each test case runs successfully.  Please  bear with me I just started using these tools not familiar with it whole lot, any help will be appreciated very much.
Thanks Netra

################## PLEASE REFER BELOW CODE FOR ABOVE EXPLANATION ##################

package com.features.NewTry;

import java.io.File;

import java.net.MalformedURLException;

import java.net.URL;

import org.junit.Before;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.openqa.selenium.Platform;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.remote.DesiredCapabilities;

import org.openqa.selenium.remote.RemoteWebDriver;

import com.steps.NewTryTwoSteps;

import net.serenitybdd.junit.runners.SerenityRunner;

import net.thucydides.core.annotations.Managed;

import net.thucydides.core.annotations.Steps;

@RunWith(SerenityRunner.class)

public class NewTryThreeTest {

// @Managed(uniqueSession = true)

// @Managed(driver = "chrome")

@Managed

// public WebDriver webdriver;

public WebDriver driver = null;

// public RemoteWebDriver driver;

// public ChromeDriver webdriver;

String BaseURL;

@Steps

public NewTryTwoSteps NewEndUser;

/* @Before

public void setup() {

// System.setProperty("webdriver.iexplorer.driver", "C:/opt/IEDriverServer.exe");

System.setProperty("webdriver.iexplorer.driver", "C:/opt.IEDriverServer.exe");

} */

@Before

public void setup() throws MalformedURLException {

BaseURL="http://www.google.com";

// System.setProperty("webdriver.ie.driver", "C:/opt/IEDriverServer_x64_2.48.0");

File file = new File("C:\\opt\\IEDriverServer.exe");

// System.setProperty("webdriver.ie.driver", "C:/opt/IEDriverServer.exe");

// System.setProperty("webdriver.ie.driver", "C:/opt/IEDriverServer.exe");

System.setProperty("webdriver.ie.driver", file.getAbsolutePath());

// System.setProperty("webdriver.iexplorer.driver", file.getAbsolutePath());

DesiredCapabilities capability = DesiredCapabilities.internetExplorer();

capability.setBrowserName("internet explorer");

capability.setVersion("11.0.9600.18124");

// capability.setBrowserName("firefox");

capability.setPlatform(Platform.WINDOWS);

// capability.setPlatform(Platform.VISTA);

driver = new RemoteWebDriver (new URL("http://172.26.98.175:5555/wd/hub"), capability);

driver.get(BaseURL);

}

// WebDriver webdriver = new ChromeDriver();

@Test

public void Test_One() {

NewEndUser.Navigate_To_home_page();

NewEndUser.clickLink();

}

@Test

public void Test_Two() {

NewEndUser.Navigate_To_home_page();

NewEndUser.clickLink();

}

}

################################################

On Thursday, December 17, 2015 at 4:10:51 AM UTC-5, Harry King wrote:

John Smart

unread,
Dec 18, 2015, 10:44:55 AM12/18/15
to Netra Shivakumar, Serenity BDD Users Group
I'm not sure what your step code looks like, but it seems odd to open the URL in the @Before method - normally you would do this using a Page Object when required, e.g. in the Navigate_To_home_page method.

--
You received this message because you are subscribed to the Google Groups "Serenity BDD Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thucydides-use...@googlegroups.com.
To post to this group, send email to thucydid...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
___________________________________________________
John Smart | Wakaleo Consulting  |  +61 407 247 642
Optimizing your software development process
http://www.wakaleo.com  |  john....@wakaleo.com
___________________________________________________

We love breaking down silos and helping smart teams collaborate better! Ask about our tailored on-site workshops in Agile Requirements Discovery, Behaviour Driven Development, Agile Development Practices, and Test Automation!
___________________________________________________

Netra Shivakumar

unread,
Dec 18, 2015, 2:25:05 PM12/18/15
to Serenity BDD Users Group, netrash...@gmail.com
I added to this line - driver.get(BaseURL) of code in @Before to check browser does work at node, I do agree with you it is not good practice to add this at this place.  Following just sample codes to try serenity test cases onselenium  grid to run them on IE & Chrome.  In this I am just trying for IE.  Test cases that I developed works fine on FF, but I want to make sure I can run them on other browsers before I proceed with these tools.

Here is my Steps file & page file looks

$$$$$$$$$$$$$$$$$ Start of Step File$$$$$$$$$$$$$$$$$$

package com.steps;

 

import com.pages.TestOnePage;

import net.thucydides.core.annotations.Step;

import net.thucydides.core.steps.ScenarioSteps;

public class TestOneSteps extends ScenarioSteps {

TestOnePage tpage;

@Step

public void Navigate_To_home_page() {

tpage.open();

}

@Step

public void ClickLink() {

tpage.getGmailLinkEle().click();

}

}

$$$$$$$$$$$$$$$ End of Step File $$$$$$

%%%%%%%% Start Page file %%%%%%%%%%%%%%%

package com.pages;

import net.thucydides.core.annotations.DefaultUrl;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import net.thucydides.core.annotations.findby.FindBy;

import net.thucydides.core.pages.PageObject;

@DefaultUrl("https://google.com")

public class TestOnePage extends PageObject {

@FindBy (linkText = "Gmail") WebElement GMailLink;

WebDriver driver;

public TestOnePage (WebDriver driver){

super(driver);

}

public WebElement getGmailLinkEle() {

return GMailLink;

}

public void setLmsSupportSiteLink(WebElement SideMainMenuLink) {

GMailLink = GMailLink;

}

}

%%%%%%%%%%% End of Page file%%%%%%%

Sampathkumar S

unread,
Dec 23, 2015, 6:05:11 AM12/23/15
to Serenity BDD Users Group, netrash...@gmail.com
hi Netra,

I am bit confused about your query. This is how I managed to work with different browsers.

In your pom.xml, set the properties like you see here

 <properties>
         
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         
<serenity.version>1.1.13</serenity.version>
         
<serenity.maven.version>1.1.13</serenity.maven.version>
         
<webdriver.firefox>firefox</webdriver.firefox>
         
<webdriver.ie>webdrivers\IEDriverServer.exe</webdriver.ie> <!-- THis is where my IEdriver is located  in my project parent folder-->
           
<webdriver.chrome>webdrivers\chromedriver.exe</webdriver.chrome>

 
</properties>



If you're using surefire/failsafe plugin configure the system property in build plugins section

                   
            <configuration>
               
<runOrder>${surefire.test.runOrder}</runOrder>
               
<systemPropertyVariables>
                     
<webdriver.driver>${webdriver.firefox}</webdriver.driver>  
                   
<!-- <webdriver.firefox.bin>C:\Program Files (x86)\Mozilla Firefox\firefox.exe</webdriver.firefox.bin> -->
                     
<webdriver.ie.driver>${webdriver.ie}</webdriver.ie.driver>
                     
<webdriver.chrome.driver>${webdriver.chrome}</webdriver.chrome.driver>
               
</systemPropertyVariables>
           
</configuration>

Thats it, you're all set. Now execute Serenity BDD tests..


mvn clean verify -Dwebdriver.base.url=www.google.com -Dwebdriver.driver=iexplorer


This should work everywhere. At least for me its working in my local machine, CI tools, remoteLaunch of scripts. :) :)

 Serenity BDD is Simply awesome..
Reply all
Reply to author
Forward
0 new messages