0

Currently i run a sample test-case in Intelij using selenium in serenity

1 2 3 4 5 6 7 8 9

public class LaunchingChrome {

    public static void main(String[] args) {
        String exePath = "C:\\Users\\abc\\Desktop\\Server\\chromedriver.exe";
        System.setProperty("webdriver.chrome.driver", exePath);
        WebDriver driver = new ChromeDriver();
        driver.get("http://toolsqa.wpengine.com/automation-practice-form/");
    }
}

For the chrome driver path i have assigned a local system path . If i run the same test cases in remote machine or on server i am ending up in failure .

Now my question is how we can run ChromeDriver on the server ?

Jonathan Argentiero
  • 5,687
  • 8
  • 29
  • 34
Suhas B N
  • 1
  • 1
  • 1

1 Answers1

0

The answers above apply to Selenium. But one of the advantages of Serenity is that you don't need to do all this work to instantiate your chrome driver (and shouldn't, because you won't benefit from the Serenity reporting). It is also a bad habit to encode system paths into an automated test, as the test will now run only on your machine.

In Serenity, just make sure the chromedriver is on your system path and add the following to your JUnit test:

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

Or set the serenity.webdriver property to "chrome" on the command line or in your build file, and use the following:

@Managed WebDriver driver;

You should pretty much never need to ever do new ChromeDriver() in Serenity.

John Smart
  • 969
  • 1
  • 5
  • 5