sensiolabs / BehatPageObjectExtension

MIT License
116 stars 48 forks source link

Dupplicate session window created #80

Closed CaptainQuirk closed 7 years ago

CaptainQuirk commented 7 years ago

Hi all,

I'm trying to implement the PageObject extension into an existing Behat\Mink test harness. Before trying, I've been having some success with the following architecture:

I'm starting on a new suite and thought I'd give the following architecture a try:

If I leave the $session->start() in my ParentContext, a first browser window spawns, like it would before, but before any other instructions are executed (even if I comment out the $loginPage->open(), a second browser window spawns.

If I remove the $session->start() in the ParentContext, any subsequent attempt at $loginPage->open() fails, as if it would need a session to not use it at all.

Could someone give me his/her opinion on the architecture I've chosen and maybe some pointers on what I'm doing wrong ?

Thanks in advance

jakzal commented 7 years ago

Even without page object extension, you don't need to manually start the mink session. MinkExtension will do this for you. Do you use the MinkExtension for Behat?

CaptainQuirk commented 7 years ago

I do ! But I had to do a

$session = new Behat\Mink\Session;
$session->start();

If the session is started automatically, where does it occur and how can I get a reference on it ?

By the way, I decided ro create an extension to register a custom PageObjectFactory and it solved this particular issue.

Thanks !

jakzal commented 7 years ago

I think it's Mink that starts the session when you request it: https://github.com/Behat/Mink/blob/master/src/Behat/Mink/Mink.php#L116-L118