提交带有Codeception的表单时无效的cookie
I'm trying to test my project with Codeception (acceptance tests). Everything was going fine until I had to submit a form with Paypal button.
When debugging it shows
I submit form "form:nth-child(3)",
[Uri] https://www.sandbox.paypal.com/cgi-bin/webscr
[Method] POST
[Parameters] {"cmd":"_s-xclick","hosted_button_id":"BUTTONID"}
ERROR
And then goes
[RuntimeException] Invalid cookie: The cookie value must not be empty
I DO NOT set any cookies during the test. And have no clue why is it firing this error up.
Here's my acceptance.suite.yml
class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: http://test.mysite.com
- \Helper\Acceptance
Here's my SubscriptionCest.php:
<?php
use \AcceptanceTester;
class SubscriptionCest
{
public function _before(AcceptanceTester $I)
{
}
public function _after(AcceptanceTester $I)
{
}
// Main function
public function run(AcceptanceTester $I)
{
$I->am("New user");
$I->wantTo("purchase a membership");
$I->amOnPage("/subscription");
$I->submitForm("form:nth-child(3)", []);
}
}
And here's the HTML of that paypal form:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="BUTTONID">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Why does this error happen and how to resolve this problem? Thanks.
我正在尝试使用Codeception(验收测试)测试我的项目。 一切都很顺利,直到我不得不用Paypal按钮提交表格。
当他们调试它时显示 p>
我提交表格“form:nth-child(3)” ,
[Uri] https://www.sandbox.paypal.com/cgi-bin/webscr
[Method] POST
[参数] {“cmd”:“_ s-xclick”,“hosted_button_id”:“ BUTTONID“}
ERROR
code> pre>
然后转到 p>
[RuntimeException]无效的cookie:cookie值不得 是空的
code> pre>
我不会在测试期间设置任何cookie。 并且不知道为什么它会解决这个错误。 p>
这是我的acceptance.suite.yml p>
class_name:AcceptanceTester
modules:
启用:
- PhpBrowser:
url:http://test.mysite.com
- \ Helper \ Acceptance
code> pre>
这是我的SubscriptionCest。 php: p>
&lt;?php
use \ AcceptanceTester;
class SubscriptionCest
{
public function _before(AcceptanceTester $ I)
{
} \ n
公共函数_after(AcceptanceTester $ I)
{
}
//主函数
公共函数运行(AcceptanceTester $ I)
{
$ I-&gt; am(“新用户 “);
$ I-&gt; wantTo(”购买会员资格“);
$ I-&gt; amOnPage(”/ subscription“);
$ I-&gt; submitForm(”form:nth- child(3)“,[]);
}
}
code> pre>
这是paypal形式的HTML: p>
&lt; form action =“https://www.sandbox.paypal.com/cgi-bin/webscr”method =“post”target =“_ top”&gt;
&lt; input type =“hidden “name =”cmd“val ue =“_ s-xclick”&gt;
&lt; input type =“hidden”name =“hosted_button_id”value =“BUTTONID”&gt;
&lt; input type =“image”src =“https://www.sandbox。 paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif“border =”0“name =”submit“alt =”PayPal - 更安全,更简单的在线支付方式!“&gt;
&lt; img alt =”“border =“0”src =“https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif”width =“1”height =“1”&gt;
&lt; / form&gt;
pre>
为什么会发生此错误以及如何解决此问题?
谢谢。 p>
div>
So it turned out it was a bug, which is now fixed. Version 2.1 should have it working like a charm. For more information please check out https://github.com/Codeception/Codeception/issues/2234