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

Fixes #4078 Throw NoSuchElementError instead of Timeout Error #4082

Closed
wants to merge 2 commits into from

Conversation

Honey2339
Copy link

Thanks in advance for your contribution. Please follow the below steps in submitting a pull request, as it will help us with reviewing it quicker.

  • Create a new branch from master (e.g. features/my-new-feature or issue/123-my-bugfix);
  • If you're fixing a bug also create an issue if one doesn't exist yet;
  • If it's a new feature explain why do you think it's necessary. Please check with the maintainers beforehand to make sure it is something that we will accept. Usually we only accept new features if we feel that they will benefit the entire community;
  • Please avoid sending PRs which contain drastic or low level changes. If you are certain that the changes are needed, please discuss them beforehand and indicate what the impact will be;
  • If your change is based on existing functionality please consider refactoring first. Pull requests that duplicate code will most likely be ignored;
  • Do not include changes that are not related to the issue at hand;
  • Follow the same coding style with regards to spaces, semicolons, variable naming etc.;
  • Always add unit tests - PRs without tests are most of the times ignored.

The test :

describe('duckduckgo example', function() {

  this.tags = ['end-to-end'];

  it('Search Nightwatch.js and check results', function(browser) {
    browser
      .navigateTo('https://duckduckgo.com')
      .waitForElementVisible('body')
      .assert.visible('input[name="q"]')
      .sendKeys('input[name="q"]', ['Nightwatch.js'])
      .assert.visible('button[type=submit]')
      .click('button[type=submit]')
      .assert.textContains('.react-results--main', 'Nightwatch.js');
    const result = browser.element(".invalid--serp");
    console.log(result);
  });
});

Test before changes :

 Error
   Timed out while waiting for element "By(css selector, .invalid--serp)" to be present for 5000 milliseconds.

    Error location:
    F:\Workspace 6\nightwatch\lib\api\web-element\scoped-element.js:331
    –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
     329 | function createNarrowedError({ error, condition, timeout }) {
     330 |   if (error.name === 'TimeoutError') {
     331 |     return new Error(`Timed out while waiting for element "${condition}" to be present for ${timeout} milliseconds.`); 
     332 |   } else if (error.name === 'NoSuchElementError') {
     333 |     return new Error('Element is not present');
    –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––


  FAILED: 1 errors and  4 passed (7.059s) 

Test after changes :

TEST FAILURE (8.759s):
   - 1 error during execution;
   - 0 assertions failed; 4 passed

   × 1) duckDuckGo

   – Search Nightwatch.js and check results (7.239s)


  - OTHER ERRORS:
  Error
    Error
   Element does not exist By(css selector, .invalid--serp)

    Error location:
    F:\Workspace 6\nightwatch\lib\api\web-element\scoped-element.js:331
    –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
     329 | function createNarrowedError({ error, condition, timeout }) {
     330 |   if (error.name === 'NoSuchElementError') {
     331 |     return new Error(`Element does not exist ${condition}`); 
     332 |   }
     333 |   return error;
    –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––


 Wrote HTML report file to: F:\Workspace 6\nightwatch\tests_output\nightwatch-html-report\index.html

This PR fixes #4078

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Honey2339 Honey2339 marked this pull request as draft March 3, 2024 06:42
@Honey2339 Honey2339 marked this pull request as ready for review March 3, 2024 06:48
@Honey2339 Honey2339 marked this pull request as draft March 3, 2024 06:48
@Honey2339
Copy link
Author

@garg3133 Can you review this Draft?
Thank You

@Honey2339 Honey2339 marked this pull request as ready for review March 7, 2024 02:33
@Honey2339
Copy link
Author

I've attached a video demonstrating the issue

issuedescriptionz.mp4

@garg3133
Copy link
Member

Fixed in #4193, thanks!

@garg3133 garg3133 closed this Apr 19, 2024
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

Successfully merging this pull request may close these issues.

Throwing TimeoutError when chained .find() command fails
4 participants