skip to Main Content

I’m running Codeception tests. For display purposes, I want to drive the tests on a single Chrome browser [or FF idc], and keep the browser open between test runs. I know there is a way to do this [I did it, but forgot how!].

I’m running:
Ubuntu 20
google-chrome 86

Currently, the tests run fine, and the GUI pops up, but then closes at the end of the run.

I think it has something to do with the parameter "browserSessionReuse" or "restart" or "detach" but I can’t figure out where to put it, especially in PHP!

How can I use just one browser, and keep using it, it Codeception?

yml:

class_name: AcceptanceTester
modules:
  enabled:
    - HelperAcceptance
    - WebDriver
  config:
    WebDriver:
      url: 'http://xx123xxx.com/'
      port: 4444
      browser: chrome

How I launch Selenium:

java -Dwebdriver.chrome.driver=/var/www/html/wp-content/plugins/WPbdd/chromedriver -jar selenium.jar

2

Answers


  1. I’m sorry for not answering exatly what you desire, but I think there is no way to do that.

    But I suggest you to use codeception console for run one-by-one acceptance test instructions, so this will keep the browser open while you see each command being executed.

    And if you use Docker, I suggest you to take a look at this link, for using selenium and Chrome Drive in containers and you may access the interface thru NoVNC (remote desktop access in browser):
    https://hub.docker.com/r/selenium/hub

    Feel free to contact me if you need help with Docker for running that.

    Login or Signup to reply.
  2. UPDATE: Original question was about restart between tests not between test runs.

    NEW ANSWER:

    Codeception WebDriver module can’t do that, but you can implement such functionality yourself.

    You would have to create your own module, make it extend WebDriver, overwrite _after and _afterSuite method to prevent them from stopping browser instance.
    Then implement storing selenium session id to file in _afterSuite and update _initializeSession method to read session id from file and pass it to constructor of RemoteWebDriver , you will have to copy some core from RemoteWebDriver::create method too.

    ORIGINAL ANSWER:

    That’s the default behaviour!
    By default WebDriver module reuses the same browser session for all tests and only deletes cookies between tests.
    It is possible to make it restart browser between tests by setting restart: true parameter.

    Another way to restart browser is to call _restart method in helpers, is there any chance that your Acceptance Helper is executing it?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search