douwuli4512 2015-08-03 05:36
浏览 98
已采纳

提交带有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.

  • 写回答

1条回答 默认 最新

  • duanlanzhi5509 2015-08-06 08:59
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 速帮,学校需要在外上班没空
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改
  • ¥15 Windows 系统cmd后提示“加载用户设置时遇到错误”
  • ¥50 vue router 动态路由问题
  • ¥15 关于#.net#的问题:End Function
  • ¥15 无法import pycausal
  • ¥15 VS2022创建MVC framework提示:预安装的程序包具有对缺少的注册表值的引用
  • ¥15 weditor无法连接模拟器Local server not started, start with?
  • ¥20 6-3 String类定义