使用 Codeception 检查外部重定向

2tu*_*els 5 php testing codeception

我想检查这样的事情:

<?php

$I->amOnPage('/go/google');
$I->seeCurrentUrlEquals('http://google.com');
Run Code Online (Sandbox Code Playgroud)

但我得到错误:

Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'http://google.com'
+''

Scenario Steps:
2. I see current url equals "http://google.com"
1. I am on page "/go/google"
Run Code Online (Sandbox Code Playgroud)

想法只是检查用户是否被重定向到外部资源。

ric*_*yce 0

您想使用哪种浏览器?大多数浏览器需要一些时间来解释重定向。访问网站“/go/google”后,测试立即运行网址检查,这可能比浏览器执行重定向更快。再给它一点时间。

尝试:

<?php

$I->amOnPage('/go/google');
$I->wait(2);
$I->seeCurrentUrlEquals('http://google.com');
Run Code Online (Sandbox Code Playgroud)

亲切的问候