不使用量角器框架调用Safari浏览器

时间:2016-04-08 07:09:52

标签: selenium-webdriver safari protractor

我正在尝试在Safari浏览器上运行测试,它在运行selenium服务器时使用selenium" selenium-server-standalone-2.47.1.jar"它工作正常。

我已经下载并安装了safari webdriver驱动程序扩展。 使用Safari浏览器:5.1.7在窗口机器上。 我在conf文件中添加了浏览器配置:      ' browserName':' safari'"

当我使用

运行服务器时
  

webdriver-manager start

获取以下异常和Safari浏览器未启动。

:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-
webdriver\error.js:27
super(opt_error);
     ^
WebDriverError: The best matching driver provider org.openqa.selenium.ie.InternetExplorerDriver can't create a new driver instance for Capabilities [{count=1, browserName=safari}]
 Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'
 System info: host: 'Admin-PC', ip: '10.253.10.4', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_65'
 Driver info: driver.version: unknown at WebDriverError C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\error.js:27:10)
 at Object.checkLegacyResponse (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\error.js:580:13)
   at C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:64:13
  at Promise.invokeCallback_ (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1329:14)
  at TaskQueue.execute_ (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2790:14)
at TaskQueue.executeNext_ (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2773:21)
at C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2652:27
at C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7 at process._tickCallback (node.js:369:9)From: Task: WebDriver.createSession()
at acquireSession (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:62:22)
at Function.createSession (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\seleniu-webdriver\lib\webdriver.js:295:12) at Builder.build (C:\Users\Admin\AppData\R                           oaming\npm\node_modules\protractor\node_modules\selenium-webdriver\builder.js:458:24)
at [object Object].DriverProvider.getNewDriver (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\built\driverProviders\driverProvider.js:42:27)
at [object Object].Runner.createBrowser (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\built\runner.js:203:37)
at C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\built\runner.js:293:21
at _fulfilled (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
at C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:556:49

让我知道我错过了什么。

1 个答案:

答案 0 :(得分:0)

我相信你应该像这样使用

multiCapabilities: [{
        name: 'ChromeIphone',
        logName: 'Chrome Iphone',
        browserName: 'chrome',
        chromeOptions: {
            'args': ['user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A405 Safari/600.1.4']
        },
        mobileEmulationEnabled: true
    }]
在您的conf.js文件中

导致量角器在带有铬的Windows机器上工作,您必须设置user-agent参数以显示您通过safari浏览器转到您的页面。因此,您无法仅通过Chrome驱动程序直接在Windows机器上运行Safari浏览器。