Durgesh
Durgesh

Reputation: 595

Serenity BDD test cases are not running on Chrome browser

My Serenity BDD test cases are running fine on firefox when I used below annotations in step definition file:

@Managed
public WebDriver driver;

I wanted to run same test cases on chrome browser. So, modified it as below:

@Managed(driver = "chrome")
 WebDriver driver;

Also tried below one:

@Managed(driver = "chrome")
 ChromeDriver driver;

In both the above cases, my test cases are still running by opening Firefox instead of Chrome. I followed the exact steps as per mentioned in Serenity BDD guide. Can you please help me to know, how to execute Serenity BDD test scripts by opening Chrome. Thanks in advance for your help.

Upvotes: 2

Views: 11204

Answers (3)

Santosh Pillai
Santosh Pillai

Reputation: 8633

Download the chrome web driver exe file (for mac) or jar file (for windows) and place it your project directory. Download from here.

If you have installed maven manually (and not depending only on Maven plugin in Eclipse), you can run the tests in chrome browser by :

  • Open command prompt
  • Navigate to the directory where you have the POM file for the project.
  • Execute the command - mvn clean verify -Dwebdriver.driver=chrome

Upvotes: 1

Saurabh
Saurabh

Reputation: 940

I know this can be little frustrating. I am assuming this is a maven project. You have done the first step correct by defining:

@Managed(driver = "chrome")
WebDriver driver;

Ensure that in the pom.xml, you have provided the chromedriver.exe

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          <webdriver.driver>chrome</webdriver.driver> 
        <webdriver.chrome.driver>chromedriver.exe</webdriver.chrome.driver> 
<properties>

Hope this helps. Let me know

Upvotes: 5

habsq
habsq

Reputation: 1832

I haven't used Serenity yet but I had some experience with Thucydides (Senerity's predecessor). What I did in Thucydides to add Chrome support is by editing the thucydides.properties file (typically in src/test/resources) to add these lines:

webdriver.driver=chrome
webdriver.chrome.driver = C:\\chromedriver\\chromedriver.exe

It might work similarly in Serenity.

Upvotes: 9

Related Questions