我想在Jenkins中运行我的测试硒。我使用Maven和Testng在jenkins中运行我的测试。我有一个简单的配置:
package Testselenium;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
public class NewTest {
private WebDriver driver;
@Test
public void testEasy() {
driver.get("http://localhost");
String title = driver.getTitle();
Assert.assertTrue(title.contains("TimDevOps"));
}
@BeforeTest
public void beforeTest( ) {
driver = new FirefoxDriver();
}
@AfterTest
public void afterTest() {
driver.close();
}
}
我想在Selenium IDE中配置相同的测试,但是当我解压缩我的java文件并在上面替换我的配置时它不起作用:
package com.example.tests;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
public class test extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://localhost/", "*chrome");
}
public void testTest() throws Exception {
selenium.open("/");
selenium.click("css=input[type=\"button\"]");
selenium.click("css=input[type=\"button\"]");
selenium.click("css=input[type=\"button\"]");
selenium.click("css=input[type=\"button\"]");
}
}
Eclipse不知道selenium对象。
有人知道我怎么能混合两个文件?提前谢谢
答案 0 :(得分:0)
我不确定我是否理解你的问题。但我猜这是你想要的。
package Testselemium;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.thoughtworks.selenium.*;
public class NewTest extends SeleneseTestCase {
private WebDriver driver;
@Test
public void testEasy() {
driver.get("http://localhost");
String title = driver.getTitle();
Assert.assertTrue(title.contains("TimDevOps"));
}
@Test
public void testTest() throws Exception {
selenium.open("/");
selenium.click("css=input[type=\"button\"]");
selenium.click("css=input[type=\"button\"]");
selenium.click("css=input[type=\"button\"]");
selenium.click("css=input[type=\"button\"]");
}
@BeforeTest
public void beforeTest() {
driver = new FirefoxDriver();
}
@AfterTest
public void afterTest () {
driver.close();
}
}