【发布时间】:2019-02-07 16:24:42
【问题描述】:
我正在寻找一种方法来从命令行覆盖我的测试的基本 url。以后我会测试很多网站,所以如果我必须在acceptance.suite.yml文件中添加新环境中的每个网站,这很不方便。
目前,我的acceptance.suite.yml是:
actor: AcceptanceTester
modules:
enabled:
- WebDriver:
url: http://foo.com
browser: chrome
我知道我可以在运行命令中使用“覆盖”选项,但即使我阅读了代码接收文档并浏览了帮助网站(如堆栈 overflox..),我也找不到覆盖的好方法。有人能帮我吗?
当我打印所有配置(通过./vendor/bin/concept)时,我得到:
Array
(
actor => AcceptanceTester
modules => Array
(
enabled => Array
(
0 => Array
(
WebDriver => Array
(
url => http://foo.foo
browser => chrome
)
)
1 => \Helper\Acceptance
)
config => Array
(
)
depends => Array
(
)
)
我试过了:./vendor/bin/codecept run acceptance --steps -o 'modules: enabled: 0: WebDriver: url: http://faa.faa,但测试一直在 http://foo.foo 上运行
在这个codeception issue post 中,当我们运行一个特定的套件时似乎不可能覆盖配置值(我的英语不是很好,所以也许我误解了)。所以我在我的acceptance.suite.yml 文件中添加了一个环境:
actor: AcceptanceTester
modules:
enabled:
- WebDriver:
url: http://foo.foo
browser: chrome
env:
generic:
modules:
config:
WebDriver:
url: http://faa.faa
我尝试了这些命令:
./vendor/bin/codecept run acceptance --env generic --steps -o 'env: generic: modules: config: WebDriver: url: http://faa.faa
还有
./vendor/bin/codecept run acceptance --env generic --steps -o 'WebDriver: url: http://faa.faa
什么也没发生。我的测试总是在http://foo.foo
“军团”帮助后编辑
当我使用这个acceptance.suite.yml:
actor: AcceptanceTester
modules:
enabled:
- WebDriver
config:
WebDriver:
url: ''
browser: ''
env:
chrome:
modules:
config:
WebDriver: {}
我得到一个错误:
所以当我使用这个acceptance.suite.yml 时:
actor: AcceptanceTester
modules:
enabled:
- WebDriver
config:
WebDriver:
url: ''
browser: chrome
env:
chrome:
modules:
config:
WebDriver: {}
我收到另一个错误:
如果我使用这个acceptance.suite.yml:
actor: AcceptanceTester
modules:
enabled:
- WebDriver
config:
WebDriver:
url: ''
browser: chrome
env:
chrome:
modules:
config:
WebDriver:
url: 'http://foo.foo'
browser: 'chrome'
没有错误!呜呜呜!我不在好网址 x)
我得到的网址是“数据:”,很奇怪...... 为了获取 url,我在我的测试文件中添加了这个简单的行:
$this->comment("I am on the url : " . $this->executeJS("return window.location.href") . "\n");
【问题讨论】:
-
为什么要投反对票? ://
-
我知道这不是您所要求的,但也许该链接可以帮助您实现目标 --> stackoverflow.com/questions/31874410/…
标签: codeception