How to open a url/webpage in codeception acceptance testing?

5.2k Views Asked by At

Testing framework: Codeception

How to open a url/webpage in codeception acceptance testing ?

2

There are 2 best solutions below

3
Sergey  Nazarenko On

You can open an url directly by method: amOnPage

PHP-Browser

If you are using Selenium you can see here: WebDriver

0
Jim Maguire On

You should have a webdriver enabled in your config for the suite you are using. Usually PhantomJS or Selenium for acceptance testing. You should also set a base URL. i.e.:

class_name: AcceptanceTester 
modules:
    enabled:
        - WebDriver:
            url: 'http://localhost/'
            browser: phantomjs

There are two commands:

amOnPage($page) - appends $page to URL and opens

amOnUrl($URL) - opens $URL directly

So with the above config:

$I->amOnPage("works"); //opens http://localhost/works
$I->amOnPage("http://localhost/dontwork"); //error!
$I->amOnUrl("http://localhost/works"); //opens http://localhost/works