getDriver method is not available in Page class
When I trying to use open() function then I see error message:
"getDriver" method is not available on the LoginPage (BadMethodCallException)
I noticed that it's true, Page class doesn't have this method. I use $this->getSession()->getDriver(); instead of $this->getDriver(); and it's works.
Maybe this is a simple mistake?
Umh, getDriver should be there as of
Page -- extends --> DocumentElement --> TraversableElement --> Element (here's the method).
Are you sure you're extending right Page class?
I extended class use SensioLabs\Behat\PageObjectExtension\PageObject\Page;
I look through the all extends and I think it's problem in Mink version 1.5. In this version Element class really doesn't have a getDriver() method when in 1.7 this method implemented.
Probably it would be better to add minimal stability version to documentation or to composer if it possible?
@RebOOter Take a look to https://github.com/sensiolabs/BehatPageObjectExtension/tree/v2.1.0
It has mink 1.6 https://github.com/sensiolabs/BehatPageObjectExtension/blob/v2.1.0/composer.json#L11
Alternatively master has 1.7
Don't know if older versions need to be fixed /cc @jakzal
Yes, I see, but this requirement doesn't work if in your project will be requirement of another version. Composer doesn't tell you to use another version of Mink when it's needed.
@RebOOter that's not true because if a dependency like BehatPageObjectExtension has ^1.7 for Mink and you have specified in composer.json of your project a version of Mink <1.7, composer itself will prevent you from installing the bundle, warning about the necessity of a newer version of Mink or a lower version of this bundle.
Maybe I'm mistaken but
but this requirement doesn't work if in your project will be requirement of another version.
Another version of what? Of this bundle or of Mink?
@RebOOter can you paste relevant bits of composer show | grep behat command please? I'm mainly after behat/* and sensiolabs/behat-page-object-extension packages.
composer show | grep behat command log:
behat/behat v3.3.0 Scenario-orient...
behat/gherkin dev-master 5c14cff Gherkin DSL par...
behat/mink v1.5.0 Web acceptance ...
behat/mink-browserkit-driver v1.1.0 Symfony2 Browse...
behat/mink-extension v2.2 Mink extension ...
behat/mink-goutte-driver v1.0.9 Goutte driver f...
behat/mink-selenium2-driver v1.1.1 Selenium2 (WebD...
behat/transliterator dev-master 826ce7e String translit...
sensiolabs/behat-page-object-extension v2.0.0 Page object ext...
In composer file I have:
"behat/mink": "1.5@stable",
As you can see composer not prevent me from installing old version of Mink that doesn't have getDriver() function. PageObject extension shouldn't installed while you have version of Mink that not supported.
For now I trying to use "behat/mink": "^1.7", and this version of Mink have the getDriver() but I have another problem with 1.7 (this problem is no appeared in 1.5@stable):
Fatal error: Call to a member function open() on null (Behat\Testwork\Call\Exception\FatalThrowableError)
The same code. Changes are only in composer.json. That the reason why I use 1.5@stable version. Maybe I have some mistakes somewhere, but this behavior is still strange for me.
As I told you, v2.0.0 of this bundle doesn't take into account this whereas 2.0.1 and 2.1.0 does.
My suggestion is to upgrade to 2.0.1 at least.
Indeed, mink dependency wasn't explicit in v2.0.0. It only became apparent it's needed in v2.0.1 when we started running tests against low versions of dependencies.
I recommend updating the page object extension to the latest version.
For now I trying to use "behat/mink": "^1.7", and this version of Mink have the getDriver() but I have another problem with 1.7 (this problem is no appeared in 1.5@stable): Fatal error: Call to a member function open() on null (Behat\Testwork\Call\Exception\FatalThrowableError)
If you prepared a project to reproduce this problem I could have a look.
Here the project with this issue https://github.com/RebOOter/page-object-bug
But, I notice that in my composer file was the line with "minimum-stability": "dev". Without this option everything fine from every sides. I leave this option in the test project that you can look. I don't know where I found this, but this is the reason of my mistake. You can check the error with open() function, maybe some changes in some other library broke your library and this would help you.
Sorry for misunderstanding and thanks for advices.
I managed to pin point the problem to behat/mink. It works with the stable version, but not with the latest master. It might have something to do with https://github.com/minkphp/Mink/commit/acf5fb1ec70b7de4902daf75301356702a26e6da but I haven't looked deeper yet.
By the way, you should create page objects/elements with the factory rather than calling their constructors directly.