Tôi muốn có thể sử dụng Selenium 2 với Jenkins.Cách thực hiện các thử nghiệm Selenium 2 trong Jenkins
Tôi mới làm quen với cả hai vì vậy hãy tha thứ cho bất kỳ sự thiếu hiểu biết nào của tôi.
Tôi nhận thấy plugin sau cho jenkins HERE và đã cài đặt plugin.
Tôi có một lớp cơ sở như sau:
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; } }
tôi có cấu hình sau trên Selenium Plugin cho Jenkins:
..
Khi tôi cố gắng xây dựng dự án và chạy thử nghiệm Junit selenium trong Jenkins, nó xây dựng thành công, nhưng thử nghiệm nó tự thất bại. (Chỉ hoạt động tốt khi chạy với kiến từ dòng lệnh - và thay đổi WebDriver
tới: driver = new FirefoxDriver();
) - Sử dụng selen RC
Đây là giao diện điều khiển đầu ra trong Jenkins:
EDIT: Tôi chỉ nhận thấy bạn có thể lưu trữ tập tin đầu ra Junit .xml sau khi xây dựng trong Jenkins. Tôi nhận được một lớp học không tìm thấy ngoại lệ? Điều này là lạ bởi vì như tôi đã nói, nó xây dựng tốt khi sử dụng ant
từ dòng lệnh.
Các lỗi như sau:
<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>
Cảm ơn trước cho bất kỳ hướng nào hay giúp bạn có thể có!
Tôi cũng gặp sự cố khi tích hợp Selenium 2 + Jenkins. Tôi có thể chạy thử nghiệm selen của tôi trong jenkins. Nhưng tôi không thể khởi động trình duyệt thông qua jenkins. Nó chạy như trình duyệt không đầu. Tôi có thể biết thời tiết có thể làm được không? Nếu có xin vui lòng chia sẻ làm thế nào để làm điều đó. Xin vui lòng chia sẻ nếu bạn có hướng dẫn tốt đẹp. – Manigandan
Có, tôi đã có thể làm điều đó với firefox trên cả MAC OSX 10.8.3 và Windows 7. Bạn phải sử dụng cấu hình nút trình điều khiển web tùy chỉnh như tôi đã nói ở trên và nó sẽ khởi chạy broswer nếu bạn đã thiết lập một lưới selen với firefox được cấu hình. Tôi không thể tìm thấy bất kỳ hướng dẫn tốt về điều này. Chúc may mắn! – Curt