我让browserstack使用了我未设置的自动化框架,而我的本地测试(我正在测试的网站仍在开发中,因此不在DNS上)确实在browserstack上运行了以下环境/配置浏览器堆栈在不断变化。
它总是运行chrome版本,有时运行其他72次,例如49、69等,与OS相同,有时运行Windows 10、7、8,xp,有时也运行OSX的随机版本!
我已经厌倦了在浏览器堆栈上使用并修改示例以及在我的serenity.properties/BrowserStackSerenityTest.java中使用git hub示例以及运行该示例但没有运气的类来查看宁静的页面。我现在已经有几个小时要调整和更改thease三个文件,以获得一些稳定性,而且不知道该怎么做
我对Java和自动化还很缺乏经验,并且想尝试在尝试在浏览器堆栈中设置运行测试和并行操作之前修复和完善测试堆栈
我的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
我正在从
运行测试的TestRunner.java 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;
我的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();
}
}
}
答案 0 :(得分:0)
我不得不通过反复试验来调整serenity.properties
文件,因为通过阅读Browserstack文档并不明显,并且因为Browserstack代码依赖于非常老的Serenity框架版本:
environment.parallel_1.name = parallel_test
environment.parallel_1.browser = Chrome
environment.parallel_1.browser_version = 73.0 beta
environment.parallel_1.os = OS X
environment.parallel_1.os_version = Mojave
environment.parallel_1.resolution = 1280x1024
environment.parallel_1.browserstack.local = true
environment.parallel_2.name = parallel_test
environment.parallel_2.browser = IE
environment.parallel_2.browser_version = 11
environment.parallel_2.os = Windows
environment.parallel_2.os_version = 7
environment.parallel_2.resolution = 1280x1024
environment.parallel_2.browserstack.local = true
您可以在此处查看代码: https://github.com/izaac/serenity-cucumber4