CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

The error message has changed !!!

Open xeonarno opened this issue 8 years ago • 4 comments

What are you trying to achieve?

I just run a simple test (codecepjs run --steps)

What do you get instead?

No error at the end but everytime I start the test I get the error.

Provide console output if related. Use --verbose mode for more details.

The interesting part :

 NoSuchAlertError: No modal dialog is currently open
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'local', ip: 'xxxxxxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_162'
Driver info: driver.version: unknown

this alert comes at the end.

Provide test source code if related


Feature('Login');

const account  = process.env.ACCOUNT;
const password = process.env.PASSWORD;

Scenario('Login Auth0  @smoke', (I) => {
    I.amOnPage("/");
    I.wait(1);
    I.fillField("email",account);
    I.wait(1);
    I.fillField("password",password);
    I.click({css:"button.auth0-lock-submit"});
    I.waitForElement({css:'h1.trending-ttl'});
    I.wait(1);
    I.see('Top sources', {css:'h1.trending-ttl'});
});

The problem comes from this code :

/**
   * Grab the text within the popup. If no popup is visible then it will return null
   *
   * ```js
   * await I.grabPopupText();
   * ```
   */
  async grabPopupText() {
    try {
      const dialog = await this.browser.switchTo().alert();

      if (dialog) {
        return dialog.getText();
      }
    } catch (e) {
      if (e.message.indexOf('no alert open') > -1) {
        // Don't throw an error
        return null;
      }
      throw e;
    }
  }

the line

 if (e.message.indexOf('no alert open') > -1)

should be replaced by :

if(e.message.match(/\no\b.*\balert|model\b/i)

Need to test the regex please ! (the idea is to test if any expression like : No modal, no such alert, no alert ... no + (alert or modal)

Details

  • CodeceptJS version: v1.2.1
  • NodeJS Version: v9.7.1
  • Operating System: OSX Sierra 10.12.6 (chrome 67, firefox 60)
  • Protractor || WebDriverIO || Nightmare version (if related) Protractor !
  • Configuration file:
exports.config = {
  tests:"./../ui/**/*_test.js",
  timeout:10000,
  output:"./../reports",
  helpers: {
    Protractor:require("./protractor.conf")
  },
  angular:true,
  bootstrap:false,
  mocha: require("./mocha.conf") || {},
  multiple:{
    basic:{
      chunks:2,
      browsers:["chrome", "firefox"] 
    },
    smoke:{
      grep:"@smoke",
      outputName:"smoke",
      browsers: ["chrome", "firefox"]
    }
  }
};

in protractor.conf.js

module.exports = {
      url: process.env.BASE_URL, //|| 'http://localhost:4444/wd/hub'
      driver: "hosted",
      browser: "chrome",
      rootElement: "body",
      allScriptsTimeout: 10000,
      smartWait: 5000,
      useAllAngular2AppRoots: true,
      capabilities:capabilities[0]
    }

const capabilities = [{
  name:dateFormat(new Date(),"mmm-dd HH:MM")+" > "+"Chrome -- " || "ECHO",
  build:process.env.VERSION || "TEST",
  browser_api_name: "Chrome66x64",
  browserName: "Chrome", 
  os_api_name: "Win10", 
  screen_resolution: "1024x768", 
  record_video: "true",
  record_network: "true",
  record_snapshot: "true",
}];

xeonarno avatar Jun 26 '18 09:06 xeonarno

Oh my, there was a very recent PR which was supposed to fix that #1104 And there is this check https://github.com/Codeception/CodeceptJS/blob/master/lib/helper/Protractor.js#L1079

When did the message changed?

DavertMik avatar Jun 26 '18 09:06 DavertMik

I didn't see the PR... but Firefox has an alert with the word "modal" in it and no "alert" in it. I suggest to let a Regex with "no"+("alert" or "modal"). It will be more flexible for future possibilities.

xeonarno avatar Jun 28 '18 22:06 xeonarno

Thanks. The next patch version coming soon (I hope tomorrow) with a fix for that

DavertMik avatar Jun 28 '18 23:06 DavertMik

Fixed in 1.3.1

DavertMik avatar Jul 10 '18 23:07 DavertMik