用chromedriver测试ubuntu 16.04上的硒

时间:2017-12-15 09:48:57

标签: selenium ubuntu testng selenium-chromedriver

我在UBUNTU 16.04

当我运行此测试时:

sudo java -jar SeleniumTest.jar Driver Chrome Import Accounts.xml BaseUrl https://URL

输出:

Dec 15, 2017 3:46:22 AM com.company.vip.core.CoreManager main
INFO: Detected OS is : Linux
Dec 15, 2017 3:46:22 AM com.company.vip.core.CoreManager main
INFO: Loading App Config Data
Dec 15, 2017 3:46:22 AM com.company.vip.core.CoreManager main
INFO: App Configuration loaded Successfully
Dec 15, 2017 3:46:22 AM com.company.vip.core.CoreManager main
INFO: Starting Test Automation ...
Dec 15, 2017 3:46:22 AM com.company.vip.core.CoreManager main
INFO: Running All Tests
Dec 15, 2017 3:46:22 AM com.company.vip.core.CoreManager main
INFO: Starting Test Cases ...
[TestNG] Running:
  /opt/old/VIP2/testresources/Login.xml

Dec 15, 2017 3:46:22 AM com.company.vip.tests.Login.LoginSuite BeforeSuiteMethod
SEVERE: Chrome driver path is either unreadable or unassigned. Please configure your AppConfig.xml
Dec 15, 2017 3:46:22 AM com.company.vip.tests.Login.Login TestInvalidUserLogin
INFO: Starting TestInvalidUserLogin
Dec 15, 2017 3:46:22 AM com.company.vip.tests.Login.LoginSuite AfterMethod
SEVERE: Test Case : Login.TestInvalidUserLogin()[pri:0, instance:com.company.vip.tests.Login.Login@17579e0f] Failed
Dec 15, 2017 3:46:22 AM com.company.vip.tests.Login.Login TestValidUserLogin
INFO: Starting TestValidUserLogin
Dec 15, 2017 3:46:22 AM com.ilerra.vip.tests.Login.LoginSuite AfterMethod
SEVERE: Test Case : Login.TestValidUserLogin()[pri:0, instance:com.company.vip.tests.Login.Login@17579e0f] Failed
Dec 15, 2017 3:46:22 AM com.company.vip.tests.Login.LoginSuite AfterMethod
SEVERE: Test Case : SignUp.TestUserSignUp()[pri:0, instance:com.company.vip.tests.Login.SignUp@34cd072c] Failed

===============================================
LoginSuite
Total tests run: 3, Failures: 3, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================

[TestNG] Running:
  /opt/old/VIP2/TestNG.xml


===============================================
allSuites
Total tests run: 3, Failures: 3, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================

Xvfb stopping
Finished: SUCCESS

Appconfig.xml的内容:

<?xml version="1.0" encoding="UTF-8"?>
<AppConfig>
    <Environment>Staging</Environment>
    <ChromePath>/usr/local/bin/chromedriver</ChromePath>
    <ChromeProfile>/home/usr/.config/google-chrome/Default/</ChromeProfile>
    <ChromeIsHeadless>1</ChromeIsHeadless>
    <ImportParamsFrom>App</ImportParamsFrom>
</AppConfig>

1 个答案:

答案 0 :(得分:0)

经过多次尝试和排除故障后,我发现:

1-您应该使用普通用户运行测试(如果您使用root启动它,那么与chrome相关的内容将失败) 2-你必须对chromedriver有x许可 3-你必须在Appconfig.xml文件上传递所有参数,如完全传递给chromedriver和chrome profile