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

isOpen method hiding exception messages #57

Open
tebs opened this issue Apr 14, 2015 · 3 comments
Open

isOpen method hiding exception messages #57

tebs opened this issue Apr 14, 2015 · 3 comments

Comments

@tebs
Copy link

tebs commented Apr 14, 2015

Hi,

I'm using the isOpen method (from SensioLabs\Behat\PageObjectExtension\PageObject\Page class) like this:

PHPUnit_Framework_Assert::assertTrue(
            $this->getPage('Home page')->isOpen(),
            'Home page is not open'
        );

The problem is that when the page fails to open I have no clue why, just my generic message 'Home page is not open'. This is because isOpen method is catching all the exceptions thrown during verification (and their useful messages).

I did a workaround and overrode the isOpen method without the try/catch, but, from my point of view Page public interface should provide this.

What do you think?

Thanks!

@jakzal
Copy link
Member

jakzal commented Apr 14, 2015

I usually implement an after step hook, which outputs html on failed step (or part of it, or a screenshot if driver supports it). Would a built in support for this kind of thing solve your problem?

@tebs
Copy link
Author

tebs commented Apr 27, 2015

Well, it would definitely help for most of the cases. In my case, what was 'failing' was that the url was different after attempting to submit a form with non valid data, so the wonderful message thrown by the verifyUrl method was lost.

I did a workaround by overriding the isOpen method in my BasePage class as follows:

    public function isOpen(array $urlParameters = array())
    {
        $this->verify($urlParameters);

        return true;
    }

So I don't lost the exception messages.

I checked the history of that method and at the beginning it didn't catch the exceptions but was changed to return a boolean value.

@PWalkow
Copy link

PWalkow commented Jun 2, 2016

@jakzal Yes, build-in support would be the best idea rather than adding this step manually to all projects and/or base pages. Debugging while errors are hidden is almost impossible.

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