Skip to content

[Regression] grabFromCurrentUrl() doesn't work with REST in v2.2 #3197

Closed

Description

@konstin

After upgrading to v2.2, grabFromCurrentUrl() does no longer return the url requested using sendGET() but instead errors after printing [LogicException] The page history is empty.. This change is not mentioned in the release notes.

Minimal example

The following example works v2.1 but fails in v2.2
acceptance.suite.yml:

class_name: AcceptanceTester
modules:
    enabled:
        - REST:
            depends: PhpBrowser
            url: http://localhost:8080
        - PhpBrowser

acceptance/grabUrlCept.cept:

$I = new AcceptanceTester($scenario);
$I->wantTo('I want to retrieve the current URL');
$I->sendGET('/');
$I->grabFromCurrentUrl();

Activity

  1. Naktibalda commented on Jun 9, 2016

    @Naktibalda
    Member

    I think that this is not even a bug,
    sendGET is a REST method, grabFromCurrentUrl is a method of PhpBrowser - mixing methods of REST module and connection module in one test is not documented and not recommended

  2. Naktibalda commented on Jun 9, 2016

    @Naktibalda
    Member

    REST requests are no longer added to browser history, so PhpBrowser methods that are relying on history are not working.

  3. konstin commented on Jun 9, 2016

    @konstin
    Author

    I think that this is not even a bug,
    sendGET is a REST method, grabFromCurrentUrl is a method of PhpBrowser - mixing methods of REST module and connection module in one test is not documented and not recommended

    I'm actually not keen on mixing them, but the REST modules lacks an analogous method.

    REST requests are no longer added to browser history, so PhpBrowser methods that are relying on history are not working.

    What's the reason for this behavior? And why is a breaking change like this one not mentioned in the release notes?

  4. DavertMik commented on Jun 16, 2016

    @DavertMik
    Member

    And why is a breaking change like this one not mentioned in the release notes?

    Yes, this was our fault. I think we had a discussion about history list for REST module but forgot to set it in the changelog. Sorry.

    Basically REST module doesn't change history so can't access current URL.

    There is a good reason for that. If you need to execute API requests inside PhpBrowser acceptance test you shouldn't have it to change request history. This way you can be sure that *currentUrl methods work only with currently opened web page.

    REST modules lacks an analogous method.

    Yes, there is no. Could you provide a use case for it? This way we could also agree on a patch to Codeception or provie an alternative way to solve your issue.

  5. konstin commented on Jun 20, 2016

    @konstin
    Author

    The grabFromCurrentUrl() is required for an actor method that verifies that a value in the JSON response equals the requested URL. This is a requirement of the API. This is what I assume to add the missing functionality.

  6. konstin commented on Aug 15, 2016

    @konstin
    Author

    @DavertMik: Any progress here?

  7. added a commit that references this issue on Aug 15, 2016
    23f1526
  8. konstin commented on Aug 27, 2016

    @konstin
    Author

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions