Behat/Mink/Selenium测试失败(macOS) [英] Behat / Mink / Selenium testing broken (macOS)

查看:81
本文介绍了Behat/Mink/Selenium测试失败(macOS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Selenium进行自动浏览器测试已有相当一段时间了.我从来没有想过如何让它在Firefox以外的任何其他版本上运行.好了,现在FireFox将启动,但不会被拉到最前面,它只是坐在那儿,什么也不做.我觉得这是因为FireFox会自我更新.

I have been using Selenium for quite some time for automated browser testing. I never did figure out how to get it to run in anything other than Firefox. Well now FireFox will launch but won't get pulled to the front and it just sits there and does nothing. I have a feeling it's because FireFox updated itself.

我正在运行macOS Sierra.我已经在Safari中安装并启用了WebDriver 2.48扩展.

I'm running macOS Sierra. I have installed and enabled the WebDriver 2.48 extension into Safari.

我已经下载并尝试了selenium-server-standalone-2.53.1.jar和selenium-server-standalone-3.0.0-beta4.jar,但是我得到的结果不同.借助2.53.1和Firefox 49,它可以启动Firefox,但是如上所述,它只是坐在那里,什么也不做,甚至不加载URL.最终它超时并显示以下错误:

I have downloaded and tried both selenium-server-standalone-2.53.1.jar and selenium-server-standalone-3.0.0-beta4.jar but I get different results from each. With 2.53.1 and Firefox 49, it launches Firefox but as mentioned it just sits there and does nothing, it doesn't even load a URL. Eventually it times out with the following error:

无法打开连接:45000毫秒后无法连接到端口7055上的主机127.0.0.1. Firefox控制台输出: 08198ce6fd}," syncGUID:" mT5F_TRS51sP," location:" app-global," version:" 49.0.1," type:" theme," internalName:" classic/1.0, "updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png}," iconURL:null," icon64URL:null," defaultLocale:{" name:" Default," description:"默认主题.," creator:" Mozilla, "homepageURL":null,贡献者":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"/Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1475253044000,"updateDate":1475253044000,"applyBackgroundUpdates":1,"skinnable":true ,"size":7140,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[], "targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"49.0.1","maxVersion":"49.0 .1}]," targetPlatforms:[]," seen:true} 1475260611275 addons.xpi调试getModTime:{972ce4c6-7e08-4474-a285-3208198ce6fd}的递归扫描 1475260611276 DeferredSave.extensions.json调试保存更改 1475260611277 addons.xpi调试更新数据库,更改已安装的加载项 1475260611277 addons.xpi-utils调试更新加载项状态 1475260611277 addons.xpi-utils调试编写加载项列表 1475260611279 addons.xpi调试/Applications/Firefox.app/Contents/Resources/browser/features/e10srollout@mozilla.org.xpi的注册清单 1475260611279 addons.xpi调试在e10srollout@mozilla.org 1.2版上调用引导方法启动 1475260611279 addons.xpi调试/Applications/Firefox.app/Contents/Resources/browser/features/firefox@getpocket.com.xpi的注册清单 1475260611280 addons.xpi调试在firefox@getpocket.com版本1.0.4上调用引导方法启动 1475260611280 addons.xpi调试/Applications/Firefox.app/Contents/Resources/browser/features/webcompat@mozilla.org.xpi的注册清单 1475260611281 addons.xpi调试在webcompat@mozilla.org 1.0版上调用引导方法启动 1475260611284 addons.manager调试为XPIProvider注册关闭阻止程序 1475260611284 addons.manager调试提供程序已完成启动:XPIProvider 1475260611284 addons.manager调试开始提供程序:LightweightThemeManager 1475260611284 addons.manager调试为LightweightThemeManager注册关闭阻止程序 1475260611285 addons.manager调试提供程序已完成启动:LightweightThemeManager 1475260611285 addons.manager调试开始提供程序:GMPProvider 1475260611294 addons.manager调试为GMPProvider注册关闭阻止程序 1475260611294 addons.manager调试提供程序已完成启动:GMPProvider 1475260611294 addons.manager调试开始提供程序:PluginProvider 1475260611295 addons.manager调试为PluginProvider注册关闭阻止程序 1475260611295 addons.manager调试提供程序完成启动:PluginProvider 1475260611295 addons.manager调试完成启动序列 1475260611717 addons.manager调试开始提供者: 1475260611717 addons.manager调试注册用于的关机阻止程序 1475260611718 addons.manager调试提供程序已完成启动: 1475260611721 DeferredSave.extensions.json DEBUG开始写入 1475260611881 addons.repository调试未找到addons.json. 1475260611881 DeferredSave.addons.json调试保存更改 1475260611884 DeferredSave.addons.json DEBUG启动计时器 1475260611917 addons.manager调试开始提供程序:PreviousExperimentProvider 1475260611918 addons.manager调试为PreviousExperimentProvider注册关闭阻止程序 1475260611919 addons.manager调试提供程序已完成启动:PreviousExperimentProvider 1475260611924 DeferredSave.extensions.json调试成功写入 1475260611924 addons.xpi-utils DEBUG XPI数据库已保存,将模式版本首选项设置为17 1475260611942 DeferredSave.addons.json调试开始写入 1475260611957 DeferredSave.addons.json调试成功写入 (Behat \ Mink \ Exception \ DriverException)

Could not open connection: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: 08198ce6fd}","syncGUID":"mT5F_TRS51sP","location":"app-global","version":"49.0.1","type":"theme","internalName":"classic/1.0","updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"/Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1475253044000,"updateDate":1475253044000,"applyBackgroundUpdates":1,"skinnable":true,"size":7140,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"49.0.1","maxVersion":"49.0.1"}],"targetPlatforms":[],"seen":true} 1475260611275 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd} 1475260611276 DeferredSave.extensions.json DEBUG Save changes 1475260611277 addons.xpi DEBUG Updating database with changes to installed add-ons 1475260611277 addons.xpi-utils DEBUG Updating add-on states 1475260611277 addons.xpi-utils DEBUG Writing add-ons list 1475260611279 addons.xpi DEBUG Registering manifest for /Applications/Firefox.app/Contents/Resources/browser/features/e10srollout@mozilla.org.xpi 1475260611279 addons.xpi DEBUG Calling bootstrap method startup on e10srollout@mozilla.org version 1.2 1475260611279 addons.xpi DEBUG Registering manifest for /Applications/Firefox.app/Contents/Resources/browser/features/firefox@getpocket.com.xpi 1475260611280 addons.xpi DEBUG Calling bootstrap method startup on firefox@getpocket.com version 1.0.4 1475260611280 addons.xpi DEBUG Registering manifest for /Applications/Firefox.app/Contents/Resources/browser/features/webcompat@mozilla.org.xpi 1475260611281 addons.xpi DEBUG Calling bootstrap method startup on webcompat@mozilla.org version 1.0 1475260611284 addons.manager DEBUG Registering shutdown blocker for XPIProvider 1475260611284 addons.manager DEBUG Provider finished startup: XPIProvider 1475260611284 addons.manager DEBUG Starting provider: LightweightThemeManager 1475260611284 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager 1475260611285 addons.manager DEBUG Provider finished startup: LightweightThemeManager 1475260611285 addons.manager DEBUG Starting provider: GMPProvider 1475260611294 addons.manager DEBUG Registering shutdown blocker for GMPProvider 1475260611294 addons.manager DEBUG Provider finished startup: GMPProvider 1475260611294 addons.manager DEBUG Starting provider: PluginProvider 1475260611295 addons.manager DEBUG Registering shutdown blocker for PluginProvider 1475260611295 addons.manager DEBUG Provider finished startup: PluginProvider 1475260611295 addons.manager DEBUG Completed startup sequence 1475260611717 addons.manager DEBUG Starting provider: 1475260611717 addons.manager DEBUG Registering shutdown blocker for 1475260611718 addons.manager DEBUG Provider finished startup: 1475260611721 DeferredSave.extensions.json DEBUG Starting write 1475260611881 addons.repository DEBUG No addons.json found. 1475260611881 DeferredSave.addons.json DEBUG Save changes 1475260611884 DeferredSave.addons.json DEBUG Starting timer 1475260611917 addons.manager DEBUG Starting provider: PreviousExperimentProvider 1475260611918 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider 1475260611919 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider 1475260611924 DeferredSave.extensions.json DEBUG Write succeeded 1475260611924 addons.xpi-utils DEBUG XPI Database saved, setting schema version preference to 17 1475260611942 DeferredSave.addons.json DEBUG Starting write 1475260611957 DeferredSave.addons.json DEBUG Write succeeded (Behat\Mink\Exception\DriverException)

对于3.0.0-beta-4,它甚至不能启动Firefox,它只会引发以下错误:

With 3.0.0-beta-4 it doesn't even launch Firefox, it just throws the following error:

无法打开连接:必须通过webdriver.gecko.driver系统属性设置驱动程序可执行文件的路径;有关更多信息,请参见 https://github.com/mozilla/geckodriver .可以从 https://github.com/mozilla/geckodriver/releases 下载最新版本Behat \ Mink \ Exception \ DriverException)

Could not open connection: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases (Behat\Mink\Exception\DriverException)

如果我将我的behat.yml配置切换为使用Safari(browser_name: safari),则在2.53.1中,它将启动一个Safari实例,该实例也不会出现在前面或不执行任何操作(例如Firefox),我得到以下信息错误:

If I switch my behat.yml config to use Safari (browser_name: safari), with 2.53.1 it launches an instance of Safari which also does not come to the front or do anything (like Firefox) and I get the following error:

未知命令:{"id":"f3xi7h2t2u16",名称":"mouseMoveTo",参数":{"element"::wdc:1475260954832"}}(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:5毫秒 内部版本信息:版本:'2.53.1',版本:'a36b8b1',时间:'2016-06-30 17:37:03' 系统信息:主机:'flightbyte.local',ip:'127.0.0.1',操作系统名称:'Mac OS X',os.arch:'x86_64',os.version:'10 .12',java.version:' 1.8.0_101' 驱动程序信息:org.openqa.selenium.safari.SafariDriver 功能[{browserName = safari,takesScreenshot = true,javascriptEnabled = true,版本= 10.0,cssSelectorsEnabled = true,平台= MAC,secureSsl = true}] 会话ID:空(WebDriver \ Exception \ UnknownError)

Unknown command: {"id":"f3xi7h2t2u16","name":"mouseMoveTo","parameters":{"element":":wdc:1475260954832"}} (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 5 milliseconds Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03' System info: host: 'flightbyte.local', ip: '127.0.0.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12', java.version: '1.8.0_101' Driver info: org.openqa.selenium.safari.SafariDriver Capabilities [{browserName=safari, takesScreenshot=true, javascriptEnabled=true, version=10.0, cssSelectorsEnabled=true, platform=MAC, secureSsl=true}] Session ID: null (WebDriver\Exception\UnknownError)

有了3.0.0-beta4,我得到了...

With 3.0.0-beta4 I get ...

无法打开连接:null(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:0毫秒 内部版本信息:版本:'3.0.0-beta4',修订版:'3169782',时间:'2016-09-29 10:29:23 -0700' 系统信息:主机:'myapp.local',ip:'127.0.0.1',操作系统名称:'Mac OS X',os.arch:'x86_64',os.version:'10 .12',java.version:' 1.8.0_101' 驱动程序信息:driver.version:SafariDriver(Behat \ Mink \ Exception \ DriverException)

Could not open connection: null (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds Build info: version: '3.0.0-beta4', revision: '3169782', time: '2016-09-29 10:29:23 -0700' System info: host: 'myapp.local', ip: '127.0.0.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12', java.version: '1.8.0_101' Driver info: driver.version: SafariDriver (Behat\Mink\Exception\DriverException)

在上述所有情况下,我只需打开独立服务器.jar文件,然后像往常一样运行我的behat测试.今天,我想我想出了如何使chomedriver正常工作的方法,因此,当尝试将其与chrome一起使用时,我会以这种方式启动它...

In all the cases above, I simply open the standalone server .jar file then run my behat tests as I have always done. Today I think I figured out how to get the chomedriver work so when attempting to use it with chrome I launch it this way ...

java -jar -Dwebdriver.chrome.driver='/Users/me/bin/selenium/drivers/chromedriver' /Users/me/bin/selenium/selenium-server-standalone-2.53.1.jar

...,然后将我的behat.yml中的browser_name键更改为googlechrome.当我以这种方式运行它时,出现以下错误...

... and I change the browser_name key in my behat.yml to googlechrome. When I run it this way I get the following error...

无法打开连接:最佳匹配的驱动程序提供商org.openqa.selenium.safari.SafariDriver无法为功能[{browser = firefox,name = Behat Feature Suite,browserName = googlechrome,ignoreZoomSetting = false,标签= [myapp.local,PHP 7.0.10]}] 内部版本信息:版本:'2.53.1',版本:'a36b8b1',时间:'2016-06-30 17:37:03' 系统信息:主机:'myapp.local',ip:'127.0.0.1',操作系统名称:'Mac OS X',os.arch:'x86_64',os.version:'10 .12',java.version:' 1.8.0_101' 驱动程序信息:driver.version:未知(Behat \ Mink \ Exception \ DriverException)

Could not open connection: The best matching driver provider org.openqa.selenium.safari.SafariDriver can't create a new driver instance for Capabilities [{browser=firefox, name=Behat feature suite, browserName=googlechrome, ignoreZoomSetting=false, tags=[myapp.local, PHP 7.0.10]}] Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03' System info: host: 'myapp.local', ip: '127.0.0.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12', java.version: '1.8.0_101' Driver info: driver.version: unknown (Behat\Mink\Exception\DriverException)

使用3.0.0-beta4,我得到了:

And with 3.0.0-beta4 I get this:

无法打开连接:最佳匹配的驱动程序提供商org.openqa.selenium.safari.SafariDriver无法为功能[{browser = firefox,name = Behat Feature Suite,browserName = googlechrome,ignoreZoomSetting = false,标签= [flightbyte.local,PHP 7.0.10]}] 内部版本信息:版本:'3.0.0-beta4',修订版:'3169782',时间:'2016-09-29 10:29:23 -0700' 系统信息:主机:'flightbyte.local',ip:'127.0.0.1',操作系统名称:'Mac OS X',os.arch:'x86_64',os.version:'10 .12',java.version:' 1.8.0_101' 驱动程序信息:driver.version:未知(Behat \ Mink \ Exception \ DriverException)

Could not open connection: The best matching driver provider org.openqa.selenium.safari.SafariDriver can't create a new driver instance for Capabilities [{browser=firefox, name=Behat feature suite, browserName=googlechrome, ignoreZoomSetting=false, tags=[flightbyte.local, PHP 7.0.10]}] Build info: version: '3.0.0-beta4', revision: '3169782', time: '2016-09-29 10:29:23 -0700' System info: host: 'flightbyte.local', ip: '127.0.0.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12', java.version: '1.8.0_101' Driver info: driver.version: unknown (Behat\Mink\Exception\DriverException)

我的behat.yml像这样开始:

My behat.yml starts off like this:

default:
  extensions:
    Laracasts\Behat:
      env_path: .env.testing
    Behat\MinkExtension:
      default_session: laravel
      base_url: http://myapp.local:8080/
      browser_name: googlechrome (this is where I switch browsers)
      laravel: ~
      selenium2: ~

我的composer.json包含以下内容:

My composer.json contains this:

"require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~5.4",
    "phpspec/phpspec": "~2.1",
    "behat/behat": "^3.2",
    "behat/mink": "^1.7",
    "behat/mink-extension": "^2.2",
    "laracasts/behat-laravel-extension": "dev-master",
    "behat/mink-selenium2-driver": "^1.3@dev",
    "symfony/dom-crawler": "~3.0",
    "symfony/css-selector": "~3.0"
  },

我确实尝试将behat和貂皮材料的版本调整到我在packagist上看到的版本,然后进行作曲家更新.

I did try adjusting up the versions of the behat and mink stuff to what I saw on packagist, followed by composer update.

我只需要使这些测试再次起作用即可.我真的不在乎它是哪个浏览器,更希望它不是Firefox,但这是我一直忍受的,直到一切都崩溃了.

I just need to get these tests working again. I really don't care which browser it is, would prefer it not be Firefox but that's what I have lived with up until it all broke.

任何帮助将不胜感激!

推荐答案

Selenium在没有驱动程序的情况下无法与Firefox一起使用. 从Firefox 47开始,您需要下载marionette/geckodriver,以便可以运行硒自动化测试.

Selenium does not work with firefox without a driver anymore. Since Firefox 47 you need to download the marionette/geckodriver so you can run selenium automation tests.

如果您需要在Selenium 2.53.X中运行Chrome和Firefox(直到v46)(不需要运行geckodriver):

If you need to run Chrome and Firefox(Until v46) in Selenium 2.53.X (You dont need to run geckodriver):

java -jar selenium-server-standalone-2.53.1.jar -role node -host XXX.XXX.XXX.XXX -hub http://XXX.XXX.XXX.XXX:4444/grid/register -nodeTimeout 1200 maxSession 4 -browser browserName=chrome,maxInstances=4,platform=WINDOWS, -Dwebdriver.chrome.driver=chromedriver.exe -browser browserName=firefox,maxInstances=4,platform=WINDOWS

还有铬的贝加帽

Behat\MinkExtension:
        base_url: "https://www.yourpage.com"
        sessions:
            chrome_mac:
                selenium2:
                    browser: "chrome"
                    wd_host: http://XXX.XXX.XXX.XXX:4444/wd/hub
                    capabilities:
                        platform: MAC
                        browser: chrome
                        version: ""

还有Firefox的雏鸟

And the behat for firefox

Behat\MinkExtension:
        base_url: "https://www.yourpage.com"
        sessions:
            firefox_mac:
                selenium2:
                    browser: "firefox"
                    wd_host: http://XXX.XXX.XXX.XXX:4444/wd/hub
                    capabilities: { "platform": "MAC", "browser": "firefox", "version": "" }

如果您需要运行Chrome和Firefox(v47之后),则需要Selenium 3-betaN(您需要运行geckodriver): https://github.com/mozilla/geckodriver/releases

If you need to run Chrome and Firefox(After v47) you will need Selenium 3-betaN (You NEED to run geckodriver): https://github.com/mozilla/geckodriver/releases

java -Dwebdriver.chrome.driver=chromedriver.exe -Dwebdriver.gecko.driver=geckodriver.exe -jar selenium-server-standalone-3.0.0-beta4.jar

这篇关于Behat/Mink/Selenium测试失败(macOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆