2016-03-11 14 views
5

Tôi gặp phải lỗi Error: no display specified khi chạy thử nghiệm khung chơi trong Jenkins tại máy chủ FreeBSD. Vì vậy, mỗi khi tôi phải đối mặt với thời gian chờChạy firefox Xvfb không đầu bằng Jenkins để chạy kiểm tra selen

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox

Jenkins có:

1) Xvfb Plugin cài đặt

2) Chơi Framework

Các xét nghiệm được viết sử dụng thư viện selenua và selenua mô-đun cho khung chơi.

Xvfb được định cấu hình và được bật trong cấu hình công việc.

Job console đầu ra là: cấu hình

Checking out Revision 3f485bd2e3dbcfa058fc19f89ab18020e36707d8 (origin/trunk) 
... 
Xvfb starting$ /usr/local/bin//Xvfb :1 -screen 0 -fbdir /usr/local/jenkins/xvfb-9-786185694297443042.fbdir 
... 
Command detected: clean 
Command detected: deps --sync 
Command detected: precompile 
Command detected: auto-test 
[YalsTests] $ /srv/java/play/play clean 
... 
~ using java version "1.8.0_72" 
[YalsTests] $ /srv/java/play/play auto-test 
~ 14 tests to run: 
~ 
~ selenium/front/CorrectInput...   org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: 
Error: no display specified 

    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:113) 
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271) 

công việc:

[X] Start Xvfb before the build, and shut it down after. 
Xvfb specific display name 1 
Xvfb display name offset 0 

Invoke Play Framework  
Command set  Play 1.x 
Goals 
    Clean project [clean] 
    Custom parameter 
     Custom command deps --sync 
    Precompile all Java sources and templates [precompile] 
    Automatically run all application tests [auto-test] 

Trả lời

1

Nhiệm vụ selen cần biết DISPLAY rằng nó sẽ kết nối. Bạn có thể đặt nó, ví dụ: như là một biến môi trường (đừng quên để xuất khẩu nó, nếu bạn làm điều đó trong .profile)

export DISPLAY=:10 

này là dành cho bash, vỏ khác có thể cần một quá trình 2 bước:

DISPLAY=:10 
export DISPLAY 

Bạn cũng có thể chỉ định các biến tại dòng lệnh trước lệnh:

DISPLAY=:10 java -jar mySelenium.jar 
0

Bạn có thể tránh tất cả những vấn đề này bằng cách sử dụng Selenoid dự án mà bắt đầu trình duyệt không đầu tại song song trong Docker container. Hình ảnh vùng chứa được tạo bằng cách xem xét phiên bản trình duyệt web và trình duyệt tương thích. Họ cũng bao gồm phông chữ, flashplayer và như vậy. Chỉ cần chọn một trong số images hiện có và chạy thử nghiệm của bạn. Không cần cài đặt Java để chạy thử nghiệm Selenium.

Các vấn đề liên quan