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

Decouple PageObjects from Behat Implementation? #61

Open
ghost opened this issue Nov 25, 2015 · 9 comments
Open

Decouple PageObjects from Behat Implementation? #61

ghost opened this issue Nov 25, 2015 · 9 comments

Comments

@ghost
Copy link

ghost commented Nov 25, 2015

Hi there,

I have been thinking of using the page object pattern in a way to share the Objects with Symfony Webtestcases and found that the entire SensioLabs\Behat\PageObjectExtension\PageObject namespace could become an own library, making it possible to build Pageobjects for an application reusable among different test suites.

Technically it is already possible to use the PageObject Namespace in any context, however putting them in their own lib would be cleaner and not needed, Behat specific classes are not included in the project.

What do you think?

@jakzal
Copy link
Member

jakzal commented Nov 25, 2015

I actually have done this partly few months ago. I just haven't finished nor published it.

I'm pretty busy till SymfonyCon. I'll be catching up with my open source stuff in December :)

@ghost
Copy link
Author

ghost commented Nov 25, 2015

Awesome, looking forward to it :)

@jakzal
Copy link
Member

jakzal commented Nov 25, 2015

I'm not sure if you'll be able to use it Symfony test cases easily yet as currently page objects are heavily based on Mink. It might be the next step though. I'll give it a thought.

@ghost
Copy link
Author

ghost commented Nov 25, 2015

There is a Browserkit driver for mink
https://github.com/minkphp/MinkBrowserKitDriver

A Symfony specific implementation could be created as well, in order to configure the factory and if needed extend the WebTestCase analog to the Behat PageObjectAware contexts

@ghost
Copy link
Author

ghost commented Nov 25, 2015

As I see it, the building blocks are there, we only need to put them together and extract the PageObjects from this repo :)

@ghost
Copy link
Author

ghost commented Jan 12, 2016

Here is an approach to integrate the POP into Symfony WebTestCase. This is by no means a final approach, just a demo.

https://github.com/mozzymoz/e2eTests/tree/master/src/E2eTests/PopBundle

@DonCallisto
Copy link
Contributor

Yes, that's interesting even for "non-test" scenarios: I would like to scrape a site for a service on which there's any rest API or WS in general.
I can use Mink, Symfony and this extension to obtain what I need but, sadly, this extension is too bounded to Behat and this would not be suitable for a Symfony Bundle.

@jakzal any thoughts?

@jakzal
Copy link
Member

jakzal commented Feb 21, 2018

@DonCallisto I did some work which I haven't released in the end. I tried to make this in a real BC way, but since breaking changes in Mink (see #92), perhaps it's time to take this opportunity to rethink the design and come up with something new.

Page objects currently extend Mink elements, which was a cautious decision. The extensions initial focus group was testers with only basic coding experience. I don't think this is our user base at the moment.

One thing that's been in my head for quite some time is removing necessity to extend Mink elements, but provide tools to inject them directly into page object properties. We'd describe how to query elements with annotations:

class SearchPage
{
    /**
     * @FindBy(name="search_box")
     */
    private $searchInput;

    /**
     * @FindBy(id="search")
     */
    private $submit;

    /**
     * @FindBy(css=".container .message")
     */
    private $message;

    /**
     * @FindBy(xpath="//div//h1")
     */
    private $title;
}

We could start fresh by implementing this approach as a library, and then integrate it with Behat in this extension in a next major version.

@DonCallisto
Copy link
Contributor

DonCallisto commented Feb 21, 2018

@jakzal

Cool: only thing that "worry" me is about "collections", so dynamic selectors or something like this.
Of course we can put placeholders and so on, of course, but I suppose it could require a studying phase before try this.

If you want, I'm in for doing some work with you.

Just let me know when and how 😄

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

2 participants