알 수없는 오류 : Chrome 시작 실패 : 비정상적으로 종료 됨 (드라이버 정보 : chromedriver = 2.9
Debian 7에서 Selenium 테스트를 실행하려고하지만 성공하지 못했습니다.
오류는 다음과 같습니다.
unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9.248316,platform=Linux 3.2.0-4-686-pae x86) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 60.55 seconds Build info: version: '2.33.0', revision: '4ecaf82108b2a6cc6f006aae81961236eba93358', time: '2013-05-22 12:00:17' System info: os.name: 'Linux', os.arch: 'i386', os.version: '3.2.0-4-686-pae', java.version: '1.7.0_25' Driver info: org.openqa.selenium.chrome.ChromeDriver
나는이 chromedriver (29) 와 크롬 34.0.1847.76 베타 에서 실행중인 데비안 7 32 비트 . 내가 사용하고 2.33.0 셀레늄 자바
이 링크를 따라 가면 chromedriver 29 가 chrome 34에 적합한 버전입니다 . 어쨌든 이전 버전은 glibc 버전 때문에 데비안 7에서 작동하지 않습니다.
---------- ChromeDriver v2.9 (2014-01-31) ---------- Chrome v31-34 지원
[업데이트 1]
나는 자바 7 과 자바 6 모두로 시도했지만 여전히 같은 문제입니다. Java 8로 시도해 볼까요 ^^
[업데이트 2]
이 명령을 사용하여 크롬 드라이버를 테스트하고 젠킨스에 문제가 없는지 확인합니다.
curl -X POST -H "Content-Type : application / json; charset = utf-8"-d "{\"desiredCapabilities \ ": {\"platform \ ": \"ANY \ ", \"browserName \ ": \ "chrome \", \ "chromeOptions \": {\ "args \": [], \ "extensions \": []}, \ "version \": \ "\", \ "chrome.switches \" : []}} "localhost : 12495 / 세션
동일한 오류 메시지가 나타납니다.
{ "sessionId": "210f3f837a798ee68cd91f089976d0c2", "status": 13, "value": { "message": "알 수없는 오류 : Chrome 시작 실패 : 비정상적으로 종료되었습니다. \ n (드라이버 정보 : chromedriver = 2.9.248316, platform = Linux 3.2.0-4-686-pae x86) "}}
무슨 일이 일어나고 있는지 아는 데 도움을 주시면 감사하겠습니다.
감사
마침내 내 노트북 (서버)에서 Chrome 드라이버를 시작하는 Selenium 테스트를 받았습니다.
중요한 부분은 Xvfb. 이유를 묻지 말고이 사실을 수락하면 다음 단계를 따르십시오 (@Anon 대답보다 더 자세 함)
Jenkins 설정에서 전역 속성 추가
key : DISPLAY value:0:0서버
Xvfb에서 백그라운드에서 시작하십시오 .Xvfb :0 -ac -screen 0 1024x768x24 &
Jenkins 작업에 DISPLAY 매개 변수를 전달하고 있습니까?
헤드리스 모드에서도 테스트를 실행하려고한다고 가정합니다. 따라서 x 서비스 (예 : Xvfb)를 설정하고 DISPLAY 번호를 작업에 전달하십시오. 나를 위해 일했습니다.
wdio를 사용하여 Mocha 프레임 워크로 Jenkins에서 셀레늄을 실행하려고했습니다. 따라서이 문제를 해결하는 단계는 다음과 같습니다.
Google 크롬 설치
sudo apt-get update
sudo apt-get install google-chrome-stable
크롬 드라이버 설치
wget http://chromedriver.storage.googleapis.com/2.23/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
다음 명령을 실행하여 셀레늄 웹 서버를 시작하십시오.
nohup sudo Xvfb :10 -ac
export DISPLAY=:10
java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar -Dwebdriver.chrome.bin="/usr/bin/google-chrome" -Dwebdriver.chrome.driver="vendor/bin/chromedriver"
이 시작 후 wdio 명령으로 테스트합니다.
wdio wdio.conf.js
Mike R의 솔루션이 저에게 효과적입니다. 다음은 전체 명령 집합입니다.
Xvfb :99 -ac -screen 0 1280x1024x24 &
export DISPLAY=:99
nice -n 10 x11vnc 2>&1 &
나중에 google-chrome을 실행할 수 있습니다.
google-chrome --no-sandbox &
또는 셀레늄 드라이버를 통해 Google 크롬을 시작합니다 (예 :
ng e2e --serve true --port 4200 --watch true
Protractor.conf 파일 :
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['no-sandbox']
}
},
Jenkins에서 Selenium 테스트를 시작하는 동안 동일한 문제가 발생했습니다. ' 빌드 전에 Xvfb 시작 을 선택하고' 이후에 종료 '상자를 선택하고 필요한 화면 옵션을 전달했지만 여전히이 오류가 발생했습니다.
Execute Shell 상자에 다음 명령을 전달했을 때 마침내 작동했습니다.
Xvfb :99 -ac -screen 0 1280x1024x24 & nice -n 10 x11vnc 2>&1 & ... killall Xvfb
샌드 박스를 exec에 전달하는 것은 전경 또는 서비스로 창에있는 젠킨스에게 중요해 보입니다. 여기 내 해결책이 있습니다.
chromedriver가 전경에서 실행되는 Windows jenkins 슬레이브에서 실패합니다.
비슷한 설정을 실행하고 있습니다 : Selenium 3.40, Chrome 61, chromedriver 2.33은 ubuntu 16.04에서 xvfb로 실행됩니다.
간헐적으로 동일한 Chrome 오류가 발생했습니다. 때때로 chromedriver가 Chrome 프로필과 관련된 임시 파일을 정리하지 못하는 것 같습니다.
나를위한 해결 방법은 테스트를 실행하기 전에 임시 파일을 정리하는 것입니다.
rm -rf /tmp/.org.chromium.Chromium*
향후 버전의 chromedriver에서이 문제가 해결 될 것으로 예상하지만 현재로서는이 문제가 제 경우에 해결됩니다.
나는 오랫동안이 문제로 싸워 왔고, 오늘은 그것을 없애는 방법을 알아 냈고 오늘은 더 이상이 문제를 보지 않고 셀레늄을 호출하는 50 스레드 프로세스를 실행할 수 있으며 메모리 부족으로 내 컴퓨터 충돌을 중지 할 수 있습니다. 너무 많은 열린 chromedriver 프로세스에 문제가 있습니다.
- 셀레늄 3.7.1, chromedrive 2.33, java.version : '1.8.0', redhat ver '3.10.0-693.5.2.el7.x86_64', 크롬 브라우저 버전 : 60.0.3112.90을 사용하고 있습니다.
- 화면으로 열린 세션을 실행하여 세션이 종료되지 않도록합니다.
- Xvfb 실행 : nohup Xvfb -ac : 15 -screen 0 1280x1024x16 &
- .bashsh / .profile에서 DISPLAY : 15 내보내기
이 4 가지 항목은 모두가 이미 알고있는 기본 설정입니다. 이제 성공을 달성하기 위해 많은 차이를 만든 코드가 제공됩니다.
public class HttpWebClient {
public static ChromeDriverService service;
public ThreadLocal<WebDriver> threadWebDriver = new ThreadLocal<WebDriver>(){
@Override
protected WebDriver initialValue() {
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("permissions.default.stylesheet", 2);
profile.setPreference("permissions.default.image", 2);
profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", "false");
profile.setPreference(FirefoxProfile.ALLOWED_HOSTS_PREFERENCE, "localhost");
WebDriver driver = new FirefoxDriver(profile);
return driver;
};
};
public HttpWebClient(){
// fix for headless systems:
// start service first, this will create an instance at system and every time you call the
// browser will be used
// be sure you start the service only if there are no alive instances, that will prevent you to have
// multiples chromedrive instances causing it to crash
try{
if (service==null){
service = new ChromeDriverService.Builder()
.usingDriverExecutable(new File(conf.get("webdriver.chrome.driver"))) // set the chromedriver path at your system
.usingAnyFreePort()
.withEnvironment(ImmutableMap.of("DISPLAY", ":15"))
.withSilent(true)
.build();
service.start();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// my Configuration class is for good and easy setting, you can replace it by using values instead.
public WebDriver getDriverForPage(String url, Configuration conf) {
WebDriver driver = null;
DesiredCapabilities capabilities = null;
long pageLoadWait = conf.getLong("page.load.delay", 60);
try {
System.setProperty("webdriver.chrome.driver", conf.get("webdriver.chrome.driver"));
String driverType = conf.get("selenium.driver", "chrome");
capabilities = DesiredCapabilities.chrome();
String[] options = new String[] { "--start-maximized", "--headless" };
capabilities.setCapability("chrome.switches", options);
// here is where your chromedriver will call the browser
// I used to call the class ChromeDriver directly, which was causing too much problems
// when you have multiple calls
driver = new RemoteWebDriver(service.getUrl(), capabilities);
driver.manage().timeouts().pageLoadTimeout(pageLoadWait, TimeUnit.SECONDS);
driver.get(url);
// never look back
} catch (Exception e) {
if (e instanceof TimeoutException) {
LOG.debug("Crawling URL : "+url);
LOG.debug("Selenium WebDriver: Timeout Exception: Capturing whatever loaded so far...");
return driver;
}
cleanUpDriver(driver);
throw new RuntimeException(e);
}
return driver;
}
public void cleanUpDriver(WebDriver driver) {
if (driver != null) {
try {
// be sure to close every driver you opened
driver.close();
driver.quit();
//service.stop(); do not stop the service, bcz it is needed
TemporaryFilesystem.getDefaultTmpFS().deleteTemporaryFiles();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}
행운을 빕니다. 충돌 문제가 더 이상 보이지 않기를 바랍니다.
당신의 성공에 대해 언급하십시오
친애하는,
DISPLAY변수 내보내기 는 확실히 해결책이지만 설정에 따라 약간 다른 방식으로 수행해야 할 수도 있습니다.
In my case, I have two different processes: the first one starts Xvfb, the other one launches the tests. So my shell scripting knowledge is a bit rusty but I figured out that exporting the DISPLAY variable from the first process didn't make it available in the second process.
Fortunately, Selenium WebDriver allows you to 'redefine' your environment. This is my function for creating a driver for Chrome in JS. Pretty sure the equivalent exists for your programming language:
const caps = require('selenium-webdriver/lib/capabilities');
const chrome = require('selenium-webdriver/chrome');
const chromedriver = require('chromedriver');
module.exports = function (cfg) {
let serviceBuilder = new chrome.ServiceBuilder(chromedriver.path);
let options = chrome.Options.fromCapabilities(caps.Capabilities.chrome());
let service;
let myENV = new Map();
// 're-export' the `DISPLAY` variable
myENV.set('DISPLAY', ':1');
serviceBuilder.setEnvironment(myENV);
service = serviceBuilder.build();
options.addArguments('disable-setuid-sandbox');
options.addArguments('no-sandbox');
options.addArguments('allow-insecure-localhost');
options.excludeSwitches('test-type');
return chrome.Driver.createSession(options, service);
};
I had simillar issue with maven tests on x86 linux which i was using in terminal. I was logging in to linux by ssh. I started my java selenium tests by
mvn -DargLine="-Dbaseurl=http://http://127.0.0.1:8080/web/" install
Excepting my app, after running these tests I received error in logs:
unknown error: Chrome failed to start: exited abnormally
I was running these tests as root user. Before this error i received that ChromeDriver is nor present. I moved forward with this by installing ChromeDriver binary and adding it to PATH. But then i had to install google-chrome browser - ChromeDriver alone isn't enough to run tests. So the mistake is problem maybe with screen buffer in terminal window, but You can install Xvfb which is virtual screen buffer. What is important, that you should run your tests not as root, because you may receive another Chrome Browser error. So no as root i run:
export DISPLAY=:99
Xvfb :99 -ac -screen 0 1280x1024x24 &
What is important here, that in my case the number related to DISPLAY ought to be same as Xvfb :NN parameter. 99 in that case. I had another problem because i ran Xvfb with another DISPLAY value and I wanted it to stop. In order to restart Xvfb:
ps -aux | grep Xvfb
kill -9 PID
sudo rm /tmp/.X11-unix/X99
So find a process PID with grep. Kill Xvfb process. And then there is lock in /tmp/.X11-unix/XNN , so delete this lock and you can start server again. If You run not as root, set simillar displays, install google-chrome then with maven you can start selenium tests. My tests went fine with these rules and operations.
Not sure if this is stopping everyone else, but I resolved this by upgrading chromedriver and then ensuring that it was in a place that my user could read from (it seems like a lot of people encountering this are seeing it for permission reasons like me).
On Ubuntu 16.04: 1. Download chromedriver (version 2.37 for me) 2. Unzip the file 3. Install it somewhere sensible (I chose /usr/local/bin/chromedriver)
Doesn't even need to be owned by my user as long as it's globally executable (sudo chmod +x /usr/local/bin/chromedriver)
I increase max memory to start node-chrome with -Xmx3g, and it's work for me
'Program Club' 카테고리의 다른 글
| 하나의 도메인 이름에 여러 개의 해당 IP 주소가있을 수 있습니까? (0) | 2020.10.24 |
|---|---|
| PDF 형식의 C89 / C90 표준은 어디에서 찾을 수 있습니까? (0) | 2020.10.24 |
| Java 11에서 String trim () 및 strip () 메서드의 차이점 (0) | 2020.10.24 |
| NxN 이진 행렬에서 0 만 포함 된 가장 큰 직사각형 찾기 (0) | 2020.10.24 |
| WebSocket에 대한 동일 출처 정책이없는 이유는 무엇입니까? (0) | 2020.10.24 |