Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getDriver method is not available in Page class #92

Open
RebOOter opened this issue Jul 5, 2017 · 13 comments
Open

getDriver method is not available in Page class #92

RebOOter opened this issue Jul 5, 2017 · 13 comments

Comments

@RebOOter
Copy link

RebOOter commented Jul 5, 2017

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?

@DonCallisto
Copy link
Contributor

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?

@RebOOter
Copy link
Author

RebOOter commented Jul 5, 2017

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?

@DonCallisto
Copy link
Contributor

DonCallisto commented Jul 5, 2017

@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

@RebOOter
Copy link
Author

RebOOter commented Jul 5, 2017

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.

@DonCallisto
Copy link
Contributor

DonCallisto commented Jul 5, 2017

@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.

@DonCallisto
Copy link
Contributor

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?

@jakzal
Copy link
Member

jakzal commented Jul 5, 2017

@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.

@RebOOter
Copy link
Author

RebOOter commented Jul 5, 2017

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.

@DonCallisto
Copy link
Contributor

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.

@jakzal
Copy link
Member

jakzal commented Jul 6, 2017

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.

@RebOOter
Copy link
Author

RebOOter commented Jul 6, 2017

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.

@jakzal
Copy link
Member

jakzal commented Jul 7, 2017

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 minkphp/Mink@acf5fb1 but I haven't looked deeper yet.

@jakzal
Copy link
Member

jakzal commented Jul 7, 2017

By the way, you should create page objects/elements with the factory rather than calling their constructors directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants