I have got browserstack working with a automation framework that I did not setup, while my local tests (the website I'm testing is in development still and so not on a DNS) do run on browserstack the environment/configuration used by browserstack is constantly changing.
It always runs a version of chrome sometimes 72 other times 49, 69 etc, its the same with the OS sometimes its windows 10, 7, 8, xp, and sometime a random version of OSX too!
I've tired looking at browserstack's page on serenity using and modifying examples from there as well as there git hub examples in my serenity.properties/BrowserStackSerenityTest.java and the class im running the test from but with no luck. I've been at few hours now tweaking and changing thease three files to get some constancy and don't know what else to do
I'm still pretty inexperienced with Java and automation and would like to move onto fixing up and good stack of test before trying to setup running tests and parallel in browserstack
My serenity.properties
webdriver.driver = provided
webdriver.provided.type = mydriver
webdriver.provided.mydriver = com.browserstack.BrowserStackSerenityDriver
serenity.driver.capabilities = mydriver
browserstack.user=MyUserName
browserstack.key=MyKey
browserstack.server=hub-cloud.browserstack.com
browserstack.local=true
browserstack.build=serenity-browserstack
browserstack.project=MyProjectname
browserstack.debug=true
environment.local.name=TestRunner
environment.local.browser=chrome
environment.local.browser_version=72
environment.local.browserstack.local=true
browserstack.os = Windows
browserstack.os_version = 10
serenity.issue.tracker.url =
serenity.project.name = Common UI testing using Serenity and Cucumber
serenity.restart.browser.for.each = never
serenity.browser.maximized = true
serenity.dry.run=false
serenity.test.root=net.thucydides.showcase.cucumber.junit
serenity.outputDirectory = target/site/reports
webdriver.timeouts.implicitlywait = 1
webdriver.wait.for.timeout = 0
serenity.take.screenshots=BEFORE_AND_AFTER_EACH_STEP
My TestRunner.java which I'm running the tests from
import com.browserstack.BrowserStackSerenityTest;
import cucumber.api.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.runner.RunWith;
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features = "src/test/resources/features", tags = "@fixing")
public class TestRunner extends BrowserStackSerenityTest {
// @Managed(driver = "Chrome", uniqueSession = true)
// WebDriver driver;
My BrowserStackSerenityTest.java
package com.browserstack;
import com.browserstack.local.*;
import net.thucydides.core.util.EnvironmentVariables;
import net.thucydides.core.util.SystemEnvironmentVariables;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import java.util.HashMap;
import java.util.Map;
public class BrowserStackSerenityTest {
static Local bsLocal;
@BeforeClass
public static void setUp() throws Exception {
EnvironmentVariables environmentVariables = SystemEnvironmentVariables.createEnvironmentVariables();
String accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
if (accessKey == null) {
accessKey = (String) environmentVariables.getProperty("browserstack.key");
}
String environment = System.getProperty("environment");
String key = "browserstack.local";
boolean is_local = environmentVariables.getProperty(key) != null && environmentVariables.getProperty(key).equals("true");
if (environment != null && !is_local) {
key = "environment."+environment+".browserstack.local";
is_local = environmentVariables.getProperty(key) != null && environmentVariables.getProperty(key).equals("true");
}
if (is_local) {
bsLocal = new Local();
Map<String, String> bsLocalArgs = new HashMap<String, String>();
bsLocalArgs.put("key", accessKey);
bsLocal.start(bsLocalArgs);
}
}
@AfterClass
public static void tearDown() throws Exception {
if (bsLocal != null) {
bsLocal.stop();
}
}
}