我希望能够将Selenium 2与Jenkins一起使用。
我对这两者都是陌生的,所以请原谅我的无知。
我注意到jenkins HERE的以下插件,并安装了它。
我有一个基类如下:
public class BaseTestClass {
protected Properties myprops;
protected String baseurl;
protected WebDriver driver;
protected boolean acceptNextAlert = true;
protected StringBuffer verificationErrors = new StringBuffer();
public BaseTestClass()
{
try
{
myprops = TestUtil.readProps("src/MyProps.properties");
baseurl = myprops.getProperty("baseurl");
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), DesiredCapabilities.fireFox());
}
catch(Exception e)
{
e.printStackTrace();
}
}
@Before
public void setUp() throws Exception {
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
protected boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
protected String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alert.getText();
} finally {
acceptNextAlert = true;
}
}
我在用于Jenkins的Selenium插件上具有以下配置:
..
一旦我尝试构建项目并在Jenkins中运行Junit硒测试,它就可以成功构建,但是它自身的测试失败。(从命令行运行ant并将其更改WebDriver
为:时,工作正常driver = new FirefoxDriver();
)-使用Selenium RC
这是Jenkins中的控制台输出:
EDIT: I just noticed you can Archive the Junit .xml output file after the build in Jenkins. I am getting a class not found exception? This is weird because like i said, it builds just fine when using ant
from the command line.
The error is as follows:
<error message="com.loggedin.CCBreadCrumb" type="java.lang.ClassNotFoundException">
java.lang.ClassNotFoundException: com.loggedin.CCBreadCrumb at
java.net.URLClassLoader$1.run(URLClassLoader.java:366) at
java.net.URLClassLoader$1.run(URLClassLoader.java:355) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(URLClassLoader.java:354) at
java.lang.ClassLoader.loadClass(ClassLoader.java:423) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at
java.lang.ClassLoader.loadClass(ClassLoader.java:356) at java.lang.Class.forName0(Native
Method) at java.lang.Class.forName(Class.java:186)
</error>
Thanks in advance for any direction or help you may have!
I think i was making several mistakes. To resolve the Class Not Found Exception
I added the following to ant's build.xml
- (remember I am new Ant)
<target name="compile" depends="init" description="compile the source " >
<javac srcdir="src/" destdir="bin" classpathref="SeleniumCC.classpath"/>
</target>
This got my java classes compiling.
Then I had to update the selenium standalone server to the latest version (selenium-server-standalone-2.xx.x.jar
) This is located in:
jenkins_home_directory\plugins\selenium\WEB-INF\lib
Last I was trying to use the wrong configuration in the selenium plug-in (I was trying to use a Custom RC node configuration, what I needed was a Custom web driver node configuration.)
另请注意:在Red Hat上运行Selenium Server时,我必须使用Jenkins Xvfb插件安装和安装XVFB。
希望这对以后的其他人有所帮助!祝好运!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句