我有 2 个测试用户(将添加更多)。一些规范文件使用一种,另一些使用另一种。如果两个测试用例使用相同的测试用户,则它们不能一起运行。我想在硒网格中执行我的所有规范。我最终决定使用一个规范用户与一个 chrome 实例和另一个与另一个 chrome 实例对规范文件进行分组。(目前我将只使用一个 chrome 版本)现在的问题是两个 chrome 浏览器是相同的版本。如何将 2 组测试用例分开以并行运行。例如,测试用户 1 案例将在 Chrome 实例 1 上运行,而另一组测试案例将在 Chrome 实例 2 上运行。我添加了一个任意的 browser_version 来分隔多功能中的 2 组。我不认为它有效。有没有一个优雅的解决方案。为了调试,我试图通过测试中的以下几行获取特定测试使用的浏览器版本。它可能是不可能的。
(browser.multiCapabilities["browser_version"]).then(function(v){
console.log("check:" + v);
})
Run Code Online (Sandbox Code Playgroud)
;
但它给出了错误。无法读取未定义的属性“browser_version”。
以下是量角器配置文件的多功能性。我不使用高于此级别的“规格”属性。
maxSessions: 2,
multiCapabilities: [
{
'browserName': 'chrome',
'browser_version': '11.0',
shardTestFiles: false,
maxInstances: 1,
maxSessions: 1,
count: 1,
specs: [ 'test/e2e/VE1-Spec.js', 'test/e2e/VE2-Spec.js' ]
}, {
shardTestFiles: false,
'browserName': 'chrome',
'browser_version': '9.0',
maxInstances: 1,
maxSessions: 1,
count: 1,
specs: ['test/e2e/DG1-Spec.js', 'test/e2e/DG2-Spec.js']
}],
Run Code Online (Sandbox Code Playgroud) 我有一个响应式设计,我需要与之交互的很多项目都有2个WebElements.一个用于桌面,一个用于移动,我正在尝试使用PageFactory.以下是我现在要识别并与元素交互的内容.
//this returns 2 webelements, one for desktop and one for mobile
@FindBy(xpath = "//selector-dropdown/p")
private WebElement dropdown;
public void ClickDropdown() throws InterruptedException {
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.visibilityOf(dropdown)).click();
}
Run Code Online (Sandbox Code Playgroud)
我的印象是ExpectedConditions.visibilityOf(WebElement)会发现第一个元素可见.现在,当我在桌面上打开应用程序时,它会找到该元素(桌面是DOM中的第一个).但是在移动设备上,它等待可见性超时,因为它等待第一个变得可见.
我的另一种方法是使用@FindBy来声明每个元素两次,然后创建一个if语句来决定采用哪个路径.这项额外的工作是否能使其发挥作用?
我正在尝试将Allure整合到我的Maven项目中.这是我到目前为止所做的: - 安装了一个命令行并设置了类路径.作为验证的一部分,当我在控制台中运行诱惑--version时,我得到了2.4.1.- 我按照https://docs.qameta.io/allure/latest/#_testng上的说明操作, 并对那里提到的POM进行了更改.这是我的POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testautomation</groupId>
<artifactId>com.testautomation.selenium</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile>
<webdriver.chrome>src/main/resources/chromedriver.exe</webdriver.chrome>
<aspectj.version>1.8.10</aspectj.version>
<allure.version>1.5.4</allure.version>
<!--<maven.surefire.plugin.version>2.20</maven.surefire.plugin.version>-->
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>2.0-BETA19</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<compilerVersion>1.8</compilerVersion>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<systemPropertyVariables>
<webdriver.chrome.driver>${webdriver.chrome}</webdriver.chrome.driver>
</systemPropertyVariables>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency> …Run Code Online (Sandbox Code Playgroud)