Skip to content

How to Run Local Driver #127

@SysSU

Description

@SysSU

I followed the instructions per the Readme to implement this into an existing project. The tests are now all running in Browserstack, but how can I set this up to specify running the tests using Browserstack or local webdirver for each run. So for example if I'm debugging/creating a test I would like to run it against my local browser, but when I'm actually performing tests either on my local machine or on a CI/CD I would like them to run on Browserstack.

I was initially trying to accomplish this by creating an if statement based on a TestNG parameter in the setup code, but I'm not sure how to get it to work. Something like this:

  String runType = System.getProperty("runType") != null ? System.getProperty("runType") : "local";

  if (runType.equals("browserStack")) {
    // Setup browserstack driver
    System.out.println("Running on BrowserStack");
    URL bsUrl = new URL("https://hub.browserstack.com/wd/hub");
    MutableCapabilities capabilities = new MutableCapabilities();
    driver = new RemoteWebDriver(bsUrl, capabilities);
  } else {
    // Setup local driver
    driver = new ChromeDriver();
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions