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

Pass error message from wait*() methods to until() #3983

Merged
merged 3 commits into from Feb 3, 2017

Conversation

Projects
None yet
5 participants
@disc

disc commented Feb 2, 2017

Sometimes, when test failed because some element on page is missing I receive TimeOutException exception with empty message. Now I will pass error message to wait*() methods like $I->waitForText('foo', 10, 'Text foo was not found');

Aleksandr
Pass error message from wait*() methods to until()
Sometimes, when test failed because some element on page is missing I receive TimeOutException exception with empty message. Now I will pass error message to wait*() methods liek $I->waitForText('foo', 10, 'Text foo was not found');
@thespecial

This comment has been minimized.

Show comment
Hide comment
@thespecial

thespecial Feb 2, 2017

nicely done!

thespecial commented Feb 2, 2017

nicely done!

@DavertMik

This comment has been minimized.

Show comment
Hide comment
@DavertMik

DavertMik Feb 3, 2017

Member

Sorry but this breaks the compatibility with other methods. There are no thing like custom error messages in Codeception modules. Probably it's not a good thing, however, this is way it is now.

Inside our actions and assertions we try to generate error message based on action's name and its arguments. Inside waitForElement this can be printed as

sprintf("waited for %d secs but element %s still not found",
  $secs,
  \Codeception\Util\Locator::humanReadableString($selector)
);
Member

DavertMik commented Feb 3, 2017

Sorry but this breaks the compatibility with other methods. There are no thing like custom error messages in Codeception modules. Probably it's not a good thing, however, this is way it is now.

Inside our actions and assertions we try to generate error message based on action's name and its arguments. Inside waitForElement this can be printed as

sprintf("waited for %d secs but element %s still not found",
  $secs,
  \Codeception\Util\Locator::humanReadableString($selector)
);
@DavertMik

Please remove the extra parameters and replace them with generated exception messages, following the example from my comment

@DavertMik

This comment has been minimized.

Show comment
Hide comment
@DavertMik

DavertMik Feb 3, 2017

Member

@disc Thank you! Can you extend this to all wait* methods?

Member

DavertMik commented Feb 3, 2017

@disc Thank you! Can you extend this to all wait* methods?

@disc

This comment has been minimized.

Show comment
Hide comment
@disc

disc Feb 3, 2017

@DavertMik It's not necessary, because other wait* methods throws NoSuchElementException inside until()

disc commented Feb 3, 2017

@DavertMik It's not necessary, because other wait* methods throws NoSuchElementException inside until()

@DavertMik

This comment has been minimized.

Show comment
Hide comment
@DavertMik

DavertMik Feb 3, 2017

Member

I see, ok, that makes sense.

Member

DavertMik commented Feb 3, 2017

I see, ok, that makes sense.

@DavertMik DavertMik merged commit 077fa8f into Codeception:2.2 Feb 3, 2017

4 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
semaphoreci The build passed on Semaphore.
Details
wercker/build Wercker pipeline passed
Details
@DavertMik

This comment has been minimized.

Show comment
Hide comment
@DavertMik

DavertMik Feb 3, 2017

Member

Thank you!

Member

DavertMik commented Feb 3, 2017

Thank you!

@disc disc deleted the disc:patch-1 branch Feb 5, 2017

chris1312 added a commit to chris1312/Codeception that referenced this pull request Jun 16, 2017

Pass error message from wait*() methods to until() (Codeception#3983)
* Pass error message from wait*() methods to until()

Sometimes, when test failed because some element on page is missing I receive TimeOutException exception with empty message. Now I will pass error message to wait*() methods liek $I->waitForText('foo', 10, 'Text foo was not found');

* Apply formatted error message only for waitForText, waitForJS methods

* Formatting fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment