gpt4 book ai didi

selenium-webdriver - Behat + mink + Selenium2 + chromeDriver : Do not launch chrome browser

转载 作者:行者123 更新时间:2023-12-04 02:17:57 25 4
gpt4 key购买 nike

我使用的是 ubuntu 14.4。

当我运行测试时,它在 firefox 上运行良好,它会启动 FF 浏览器。

但是,当我对 Chrome 进行同样的尝试时,测试会运行,但不会启动浏览器。

Composer .json

{
"require": {
"behat/behat": "2.4.*@stable",
"behat/mink": "1.5.*@stable",
"behat/mink-goutte-driver": "*",
"behat/mink-extension": "*",
"behat/mink-selenium2-driver": "*"
}
}

behat.yml

default:
paths:
features: features
bootstrap: %behat.paths.features%/bootstrap
extensions:
Behat\MinkExtension\Extension:
base_url: 'path-to-my-site'
default_session: selenium2
browser_name: 'chrome'
goutte: ~
selenium2:
wd_host: "http://127.0.0.1:4444/wd/hub"

启动Selenium Server的命令

java -jar /path-to/selenium-server-standalone-2.47.1.jar -Dwebdriver.chrome.driver="/usr/local/share/chromedriver"

这是我上面命令的输出:

11:27:46.064 INFO - Launching a standalone Selenium Server
Setting system property webdriver.chrome.driver to /usr/local/share/chromedriver
11:27:46.101 INFO - Java: Oracle Corporation 24.72-b04
11:27:46.101 INFO - OS: Linux 3.13.0-32-generic amd64
11:27:46.113 INFO - v2.47.1, with Core v2.47.1. Built from revision 411b314
11:27:46.181 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match the current platform LINUX
11:27:46.182 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{platform=WINDOWS, browserName=MicrosoftEdge, version=}] does not match the current platform LINUX
11:27:46.182 INFO - Driver class not found: com.opera.core.systems.OperaDriver
11:27:46.182 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
11:27:46.249 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
11:27:46.249 INFO - Selenium Server is up and running

Behat测试命令:

vendor/bin/behat

行为测试的输出

Feature: Home page
I am on a home page

Scenario: Visit homepage # features/test.feature:4
Given I go to "home.html" # FeatureContext::visit()
Then I should see "We can change the world!" # FeatureContext::assertPageContainsText()
Then I follow "Register" # FeatureContext::clickLink()

1 scenario (1 passed)
3 steps (3 passed)

问题是 Test Works 但 chrome 浏览器没有启动。我做错了什么?

最佳答案

您应该在场景之前添加 @javascript 标签,因为默认情况下 behat 使用的是 goutte session ,而不是使用 selenium webdriver。更多关于 Goutte driver

@javascript
Scenario: Visit homepage

或者在behat.yml中设置默认session为selenium2

extensions:
Behat\MinkExtension\Extension:
default_session: selenium2

但在那之后 behat 将启动 firefox 浏览器,特别是启动 chrome - 你应该添加 browser_name: chrome 选项

extensions:
Behat\MinkExtension\Extension:
browser_name: chrome

你还应该为 selenium2 配置参数指定 wd_host 参数

extensions:
Behat\MinkExtension\Extension:
selenium2:
wd_host: "http://127.0.0.1:4444/wd/hub"

关于selenium-webdriver - Behat + mink + Selenium2 + chromeDriver : Do not launch chrome browser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32880568/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com