-1

I am trying to run the automated test in sauce labs for first time but I see no execution takes in sauce lab but instead execution takes place in my local machine. Since I am new to this way of running, I am not sure where is the correction to make.

Runner.java:-

package Global.ExecutionManager;

import io.cucumber.junit.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.runner.RunWith;

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(plugin = {"pretty"},
        features = "Test",
        glue = "foo"
)
public class TestRunner {

}

Feature

Feature: foo boo.

  Scenario: test
    Given Login with valid "foo" credentials

Step definition file:-

import io.cucumber.java.en.Given;
import net.thucydides.core.annotations.Step;

public class credentails extends Auth {

    public credentails() throws SQLException {
        open();
    }

    @Step
    @Given("^Login with valid \"([^\"]*)\" credentials$")
    public void login_with_valid_credentials(String userType) throws InterruptedException {
      // line of codes ....
    }
}

Serenity.properties:-

saucelabs.target.platform=Windows 10
saucelabs.driver.version=latest
saucelabs.url=https://f00:boo@ondemand.eu-central-1.saucelabs.com:443/wd/hub
saucelabs.access.key=boo
saucelabs.user.id=foo
saucelabs.test.name=testing

Expected Results:

Execution should take place in sauce lab.

Actual Results:

Execution takes place in local machine.

Learner
  • 481
  • 1
  • 15
  • 28

1 Answers1

1

OK so yes, and also no.

The yes is that a configuration like this will let you run tests; You still have to specify that you're using a remote Webdriver:

environment = run_with_saucelabs

environments {
  run_with_saucelabs {
    webdriver.driver = remote
    webdriver.remote.url = "https://un:ac@ondemand.eu-central-1.saucelabs.com/wd/hub"
    webdriver.browserName = Firefox
    webdriver.browserVersion = 87
    
    # Some W3C Capabilities
    screenResolution = "1280x1024"
    strictFileInteractability = true
    unhandledPromptBehavior = "ignore"
    timeouts {
      script = 20000
      pageLoad = 400000
      implicit = 1000
    }

    # SauceLabs-specific capabilities
    saucelabs {
      accessKey=un
      userName=ac
      datacenter = "eu-central-1"
    }
  }
}

The no is that as of writing this response, Serenity is still establishing Selenium sessions with the version capability, one of the older JWP capabilities. That will prevent sessions from actually starting on Sauce Labs (as mixing W3C capabilities with JWP is invalid).

Thankfully, 5 days ago a commit was made to the Serenity project to move to Selenium 4.3.0, which provides the browserVersion capability by default; That should make everything run smoothly. It looks like that'll be available in Serenity 3.2.6.

Dylan Lacey
  • 1,839
  • 12
  • 23