量角器未能开始使用firefox进行测试

时间:2017-10-14 15:14:14

标签: angular firefox protractor e2e-testing jasmine2.0

我无法在firefox版本56.0.1上使用量角器开始测试。 我的量角器版本是5.1.2

exports.config = {
    allScriptsTimeout: 11000,
    specs: [
        './e2e/**/*.e2e-spec.ts'
    ],
    capabilities: {
        'browserName': 'firefox'
    },

    directConnect: true,
    baseUrl: 'http://localhost:4444/',
    framework: 'jasmine',
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000,
        print: function() {}
    },
};

这是错误:

[00:02:20] I/launcher - Running 1 instances of WebDriver
[00:02:20] I/direct - Using FirefoxDriver directly...
[00:02:27] E/launcher - Unable to parse new session response: {"value": {"sessionId":"e9d08604-1d7e-4870-85d7-4e09a2248ffa","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"56.0.1","moz:accessibilityChecks":false,"moz:headless":false,"moz:processID":5804,"moz:profile":"C:\\Users\\s\\AppData\\Local\\Temp\\rust_mozprofile.sWpsKwszgKSw","pageLoadStrategy":"normal","platformName":"windows_nt","platformVersion":"6.1","rotatable":false,"specificationLevel":0,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}
[00:02:27] E/launcher - WebDriverError: Unable to parse new session response: {"value": {"sessionId":"e9d08604-1d7e-4870-85d7-4e09a2248ffa","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"56.0.1","moz:accessibilityChecks":false,"moz:headless":false,"moz:processID":5804,"moz:profile":"C:\\Users\\s\\AppData\\Local\\Temp\\rust_mozprofile.sWpsKwszgKSw","pageLoadStrategy":"normal","platformName":"windows_nt","platformVersion":"6.1","rotatable":false,"specificationLevel":0,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}
    at WebDriverError (C:\Users\s\WebstormProjects\Co\node_modules\selenium-webdriver\lib\error.js:27:5)
    at doSend.then.response (C:\Users\s\WebstormProjects\Common_IDE\node_modules\selenium-webdriver\lib\http.js:445:19)
    at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.createSession()
    at Function.createSession (C:\Users\s\WebstormProjects\Co\node_modules\selenium-webdriver\lib\webdriver.js:777:24)
    at Function.createSession (C:\Users\s\WebstormProjects\Co\node_modules\selenium-webdriver\firefox\index.js:640:55)
    at Direct.getNewDriver (C:\Users\s\WebstormProjects\Co\node_modules\protractor\lib\driverProviders\direct.ts:112:25)
    at Runner.createBrowser (C:\Users\s\WebstormProjects\Co\node_modules\protractor\lib\runner.ts:225:39)
    at q.then.then (C:\Users\s\WebstormProjects\Co\node_modules\protractor\lib\runner.ts:391:27)
    at _fulfilled (C:\Users\s\WebstormProjects\Co\node_modules\protractor\node_modules\q\q.js:834:54)
    at self.promiseDispatch.done (C:\Users\s\WebstormProjects\Co\node_modules\protractor\node_modules\q\q.js:863:30)
    at Promise.promise.promiseDispatch (C:\Users\saeed\WebstormProjects\Co\node_modules\protractor\node_modules\q\q.js:796:13)
    at C:\Users\s\WebstormProjects\Co\node_modules\protractor\node_modules\q\q.js:556:49
    at runSingle (C:\Users\s\WebstormProjects\Co\node_modules\protractor\node_modules\q\q.js:137:13)
[00:02:27] E/launcher - Process exited with error code 199

你知道如何解决这个问题吗? (它使用chrome正常工作但用firefox显示空页)

3 个答案:

答案 0 :(得分:0)

使用geckodriver,您需要将木偶添加到功能中:

capabilities: {
    'browserName': 'firefox',
    'marionnette': true
},

更新:Protractor 5.1.1中引入了open issue #4253。解决方法是手动将directConnect替换为seleniumAddress并按照错误中的指定手动启动webdriver-manager

  

解决方案是在使用Firefox进行测试时使用selenium standalone。   最新版本的selenium独立服务器兼容   使用Protractor的selenium JS绑定和geckodriver。您可以   使用

更新并启动独立服务器
webdriver-manager update 
webdriver-manager start 
     

并设置seleniumAddress: http://localhost:4444

答案 1 :(得分:0)

如果您选择直接连接,那么您不需要指定基本网址,也不需要明确启动webdriver服务器

exports.config = {
    allScriptsTimeout: 11000,
    specs: [
        './e2e/**/*.e2e-spec.ts'
    ],
    capabilities: {
        'browserName': 'firefox'
    },

    directConnect: true,
    framework: 'jasmine',
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000,
        print: function() {}
    },
};

答案 2 :(得分:0)

就我而言,使用“ sudo”运行它不起作用。 我必须更改文件权限,然后在没有sudo的情况下运行它。