Skip to content

Opening a page URL optionally with query string parameters #75

@walterdolce

Description

@walterdolce

Currently, the only way I can see to open a page with query string parameters it seems to be the following:

class Homepage extends Page {
   protected $path = '/?{QS}';
}

class MyContext ... {
   public function aStep() 
   {
      $this->homepage->open(array('QS' => 'utm_source=1&utm_campaign=foo'));
   }
}

This produces the expected result:

<schema>://<hostname>/?utm_source=1&utm_campaign=foo

But this way one is always forced to pass something. By leaving the array parameter passed to the open method, this is the resulting absolute URL:

<schema>://<hostname>/?{QS}

There might be cases where the behaviour of a page (or element) might vary depending on whether something's included in the URL as a query string parameter. And both cases to be verified. Creating the same page object twice (i.e. Homepage and ParameterisedHomepage) feels wrong (even if it just extend the non-parameterised page object class).

How should one deal with optional query string parameters?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions