我有一台安装了JDK&JRE 6和7的Jenkins服务器.
所有项目都建立在1.6上,除了1.7依赖项目.
我已经将maven pom文件配置为使用JAVA_HOME_7环境PATH中的Java编译器.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
**<executable>${env.JAVA_HOME_7}/bin/javac</executable>**
<fork>true</fork>
<verbose>false</verbose>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
在mvn安装期间,我收到以下错误:
java.lang.RuntimeException: There was an error in the forked process
java.lang.UnsupportedClassVersionError: : Unsupported major.minor version 51.0
Run Code Online (Sandbox Code Playgroud)
我认为这意味着服务器正在使用JRE 1.6.
如何将JRE 1.6与1.7保持在一起以保持与旧1.6项目和新1.7项目的兼容性?
非常感谢,Atanas
我有一种方法来计算元素的数量divs并返回它们的数量.
public int getNumberOfOpenBets() {
openBetsSlip = driver.findElement(By.id("form_open_bets"));
openBets = openBetsSlip.findElements(By.className(" cashout_noCash"));
return openBets.size();
}
Run Code Online (Sandbox Code Playgroud)
这是页面源
<form id="form_open_bets" method="post" name="form_open_bets">
<input type="hidden" value="" name="action">
<input type="hidden" value="" name="bet_id">
<input type="hidden" value="" name="cashout_price">
<input id="target_page" type="hidden" value="" name="target_page">
<div id="By.id" class="slipWrapper ">
<div id="openBets_header"></div>
<div id="cashout_1626" class=" cashout_noCash">
<div id="cashout_1625" class=" cashout_noCash">
<div id="cashout_1615" class=" cashout_noCash">
<div id="cashout_1614" class=" cashout_noCash">
<div id="cashout_1613" class=" cashout_noCash">
</div>
</div>
</div>
</div>
</div>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
WebDriver抛出以下错误:不支持复合类名.考虑搜索一个类名并过滤结果或使用CSS选择器.
org.openqa.selenium.InvalidSelectorException: Compound class names are not supported. …Run Code Online (Sandbox Code Playgroud) 我在mvn发布期间收到此错误:准备目标:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.2:prepare (default-cli) on project env-status-checks: Unable to tag SCM
[ERROR] Provider message:
[ERROR] The svn tag command failed.
[ERROR] Command output:
[ERROR] svn: E200007: Source and destination URLs appear not to point to the same repository.
Run Code Online (Sandbox Code Playgroud)
这是失败的SVN命令
[INFO] Tagging release with the label env-status-checks-0.0.1...
[INFO] Executing: cmd.exe /X /C "svn --username akanchev --password ***** --no-auth-cache --non-interactive copy --file C:\Windows\TEMP\maven-scm-1102804858.commit --revision 9260 svn://svn.XXXX.local/qa/XX-tf/trunk/env-status-checks http://svn.XXXX.local/qa/XX-tf/tags/env-status-checks-0.0.1"
[INFO] Working directory: C:\Users\Administrator\.jenkins\jobs\Test release\workspace
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] …Run Code Online (Sandbox Code Playgroud) 我有一个包含junit测试的Java项目,需要通过Jenkins在不同的测试环境(Dev,Staging等)上运行.
如何设置项目的构建到不同的环境以及如何将URL,用户名和密码传递给maven?
我可以使用maven 3配置文件从属性文件中读取环境URL,用户名和密码吗?
编辑:我已将配置文件添加到Project POM:
<profiles>
<profile>
<id>Integration</id>
</profile>
<profile>
<id>Staging</id>
</profile>
<profile>
<id>PP1</id>
</profile>
<profile>
<id>PP2</id>
</profile>
<profile>
<id>PP3</id>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
如何将URL,用户名和密码传递给这些配置文件?
目前,测试是从属性文件中获取测试环境详细信息:
public class BoGeneralTest extends TestCase {
protected WebDriver driver;
protected BoHomePage boHomePage;
protected static Properties systemProps;
String url = systemProps.getProperty("Url");
String username = systemProps.getProperty("Username");
String password = systemProps.getProperty("Password");
int defaultWaitTime = Integer.parseInt(systemProps.getProperty("waitTimeForElements"));
static {
systemProps = new Properties();
try {
systemProps.load(new FileReader(new File("src/test/resources/environment.properties")));
} catch (Exception e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
编辑2:
测试运行器类中实现的更改:
public class …Run Code Online (Sandbox Code Playgroud) 我需要获取一些Jenkins环境变量,如BUILD_NUMBER和BUILD_URL,并将它们作为变量注入我的Maven Java构建中.
我已将此添加到pom.xml中
<properties>
<jenkins.buildUrl>${env.BUILD_URL}</jenkins.buildUrl>
</properties>
Run Code Online (Sandbox Code Playgroud)
在使用mvn install进行构建时,我正在尝试获取变量
private static final String JENKINS_BUILD_URL = System.getProperty("jenkins.buildUrl");
Run Code Online (Sandbox Code Playgroud)
但不幸的是结果是空的......
我做错了什么?
我有一个 Java 项目,其中包含需要通过 Jenkins 在不同测试环境(Dev、Staging 等)上运行的 JUnit 测试。
我目前必须在不同环境上构建项目并将 url、用户名和密码传递给测试运行程序的解决方案是在 POM 文件中为每个环境加载特定的属性文件。将通过 Maven 构建命令为每个环境设置属性文件:
mvn clean install -DappConfig=/src/test/resouces/integration.environment.properties
在 pom.xml 中:
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<appConfig>${app.config}</appConfig>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
在 JUnit 测试运行程序类中:
public class BoGeneralTest extends TestCase {
protected WebDriver driver;
protected BoHomePage boHomePage;
protected static Properties systemProps;
String url = systemProps.getProperty("Url");
String username = systemProps.getProperty("Username");
String password = systemProps.getProperty("Password");
int defaultWaitTime = Integer.parseInt(systemProps.getProperty("waitTimeForElements"));
String regUsername = RandomStringUtils.randomAlphabetic(5);
final static String appConfigPath = System.getProperty("appConfig");
static {
systemProps = …Run Code Online (Sandbox Code Playgroud) 我有一个带两个轴的Jenkins多配置项目:
sbBrowser 值:
firefox
ie
chrome
Run Code Online (Sandbox Code Playgroud)envConfig 值:
pp1
pp2
pp3
staging
systemtest
Run Code Online (Sandbox Code Playgroud)我必须创建组合过滤器才能sbBrowser = firefox在所有的上运行envConfig.
如何构建表达式?
就像是:
sbBrowser=="firefox" && envConfig=="pp1" "pp2" "pp3" "staging" "systemtest"
Run Code Online (Sandbox Code Playgroud)