2017-09-06 8 views
2

アクセプタンステスト(concordion tests)を使用してJavaプロジェクトをセットアップしました。 クロムとphantomjsドライバ(ウィンドウ上)を使用してローカルでテストが合格(つまり、グラデーションで実行)しています。Openshift - gitlab-cli - phantomjs - WebDriverException:ドライバサーバーの起動を待ってタイムアウトしました

(openshiftで走者を)gitlab-CI上で動作しているとき、私は次の例外を取得:

java.lang.ExceptionInInitializerError 
    at be.axians.actemium.milter.helper.BrowserTestParent.openBrowser(BrowserTestParent.java:32) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 

    ... 

    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) 
    at java.lang.Thread.run(Thread.java:748) 
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start. 
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' 
System info: host: 'runner-5408090a-project-349-concurrent-0dtvl2', ip: '10.131.1.51', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-514.26.1.el7.x86_64', java.version: '1.8.0_131' 
Driver info: driver.version: PhantomJSDriver 
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:193) 
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:181) 
    at org.openqa.selenium.phantomjs.PhantomJSCommandExecutor.execute(PhantomJSCommandExecutor.java:78) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637) 
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250) 
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137) 
    at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:116) 
    at be.axians.actemium.milter.helper.WebDriverManager.<clinit>(WebDriverManager.java:53) 
    ... 52 more 
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:7465/status] to be available after 20001 ms 
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:107) 
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:190) 
    ... 60 more 
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException 
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:140) 
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:80) 
    ... 61 more 
Caused by: java.util.concurrent.TimeoutException 
    at java.util.concurrent.FutureTask.get(FutureTask.java:205) 
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:128) 
    ... 62 more 

次のようにドライバが初期化されます。指定した依存関係を持つ

 DesiredCapabilities capabilities = DesiredCapabilities.phantomjs(); 
     capabilities.setJavascriptEnabled(true); 

     PhantomJSDriverService service = new PhantomJSDriverService.Builder() 
       .usingPhantomJSExecutable(new File("/actemium/milter/acceptance-tests/driver/phantomjs/bin/phantomjs")) 
       .usingAnyFreePort() 
       .build(); 
// 
     driver = new PhantomJSDriver(service, capabilities); 

testCompile "com.codeborne:phantomjsdriver:1.4.3" 
phantomjs-1.9.8 

そして次gitlab-CI設定を持つ:

acceptance-test: 
    stage: acceptance-test 
    services: 
    - jboss/keycloak:3.3.0.CR1 
    - postgres:latest 
    variables: 
    POSTGRES_DB: "..." 
    POSTGRES_USER: "..." 
    POSTGRES_PASSWORD: "..." 
    KEYCLOAK_PASSWORD: "..." 
    KEYCLOAK_USER: "..." 
    script: 
    - ls 
    - cd acceptance-tests/driver 
    - ls 
    - tar xf phantomjs-1.9.8-linux-x86_64.tar.bz2 
    - ls -al 
    - mv phantomjs-1.9.8-linux-x86_64 phantomjs 
    - ls 
    - ls phantomjs 
    #- ls -al phantomjs/bin 
    #- ln -s phantomjs/bin/phantomjs /usr/bin/phantomjs 
    - ls -al /actemium/milter/acceptance-tests/driver/phantomjs/bin/phantomjs 
    - cd ../.. 
    - ls 
    - pwd 
    - ./gradlew -g .gradle_home acceptanceTest -Dspring.profiles.active=at --stacktrace 
    artifacts: 
    when: on_failure 
    paths: 
     - acceptance-tests/tests/build/reports/tests 
    expire_in: 1 week 

これを修正する方法は誰でも知っていますか?

答えて

1

クロームブラウザでヘッドレスを使用してすべての操作を実行できます。 HTMLUnitは構成上の問題が多いため、HTMLUnitを使用しないでください。

PhamtomJSは、ヘッドレスブラウザのもう1つのアプローチですが、PhantomJsは最近、メンテナンスが不十分でバグが発生しています。

ヘッドレスジョブには、クロムドライバ自体を使用できます。まだあなたがphantomjsを使用したい場合は

System.setProperty("webdriver.chrome.driver","D:\\Workspace\\JmeterWebdriverProject\\src\\lib\\chromedriver.exe"); 
ChromeOptions chromeOptions = new ChromeOptions(); 
chromeOptions.addArguments("--headless"); 
chromeOptions.addArguments("--start-maximized"); 
WebDriver driver = new ChromeDriver(chromeOptions); 
driver.get("https://www.google.co.in/"); 

- :

あなただけの、以下のようchromedriverに1つのオプションを渡す必要があります: -

chromeOptions.addArguments("--headless"); 

完全なコードは次のように表示されます。 は、その後最初に以下のURLからphantomjsバイナリをダウンロード: -

http://phantomjs.org/download.html

完全なコードは以下のようになります: -

System.setProperty("phantomjs.binary.path","D:\\Workspace\\kumolus-test-automation\\src\\lib\\phantomjs\\phantomjs.exe"); 
DesiredCapabilities capabilities = null; 
ArrayList<String> cliArgsCap = new ArrayList<String>(); 
capabilities = DesiredCapabilities.phantomjs(); 
cliArgsCap.add("--web-security=false"); 
cliArgsCap.add("--ssl-protocol=any"); 
cliArgsCap.add("--ignore-ssl-errors=true"); 
capabilities.setCapability("takesScreenshot", true); 
capabilities.setJavascriptEnabled(true); 
capabilities.setCapability(
    PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap); 
capabilities.setCapability(
    PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_CLI_ARGS, 
     new String[] { "--logLevel=2" }); 

WebDriver driver = new PhantomJSDriver(); 
driver.get("https://www.facebook.com/"); 
System.out.println(driver.getTitle()); 

変更phantomjsのロケーションパスの場所を上記のコードの1行目に

希望すると助かります:)

+0

私は試してみます。 PhantomJSの私の解決策は隠された依存関係をインストールすることでした:yum install -y libfontconfig1 fontconfig libfontconfig1-dev libfreetype6-dev。可能であればヘッドレスクロムを好む;) –

2

私のPhantomJS用ソリューションは、依存関係:

yum install -y libfontconfig1 fontconfig libfontconfig1-dev libfreetype6-dev 
関連する問題