Closed ituradastra closed 3 years ago
Thanks for your report. I'll look into it.
@ituradastra can you post the entire debug log?
@beatfactor I updated the bug description under Verbose output and added part of the log. Let me know if this is not the right log and if you need some more info. Apologizes for not including it from the beginning and thanks for looking into it.
Describe the bug
This error is happening only on v1.6.0, and works fine on v1.5.1 If somewhere in the test I use .useCss or .useXpath, then the next command (waitForElementVisible, in this case) won't take into account the locateStartegy of the element, but will except it to be according to the previously used .useCss() or .useXpath().
Sample test
sampleTest.js
```js // Please add the sample test here module.exports = { sampleTest: function(browser) { this.useXpath(); //some actions here this.waitForElementVisible('@nameOfTheElement'); /// some other actions } } module.exports = { commands: [Commands], elements: { nameOfTheElement:''
}
}
```
Actual Result: error appear. The supplied argument was an invalid selector (e.g. XPath/CSS). – invalid selector: Unable to locate an element with the...
Expected Result: waitForElement visible should look into the locateStartegy of the element (if not specified, default is css selector)
Run with command
Verbose output
debug.log
**The beginning of the log** Using insecure HTTP connection on port 80. Consider using SSL by setting port to 443 in your Nightwatch configuration. - Connecting to hub-cloud.browserstack.com on port 80... Request POST http://hub-cloud.browserstack.com /wd/hub/session { desiredCapabilities: { browserName: 'Chrome', javascriptEnabled: true, acceptInsecurecerts: true, 'browserstack.user': '', 'browserstack.key': '', resolution: '1280x1024', 'browserstack.selenium_version': '3.141.59', projectName: 'Regression test suite', sessionName: 'Regression test', 'browserstack.use_w3c': true, 'browserstack.idleTimeout': 500, os: 'Windows', osVersion: '10', browserVersion: '89', chromeOptions: { args: [ 'disable-gpu', '--start-maximized', '--disable-popup-blocking' ] }, / Connecting to hub-cloud.browserstack.com on port 80... Response 200 POST http://hub-cloud.browserstack.com/wd/hub/session (3872ms) { value: { acceptInsecureCerts: false, browserName: 'chrome', browserVersion: '89.0.4389.90', chrome: { chromedriverVersion: '89.0.4389.23 (61b08ee2c50024bab004e48d2b1b083cdbdac579-refs/branch-heads/4389@{#294})', userDataDir: 'C:\\Windows\\proxy\\scoped_dir5372_1870874242' }, 'goog:chromeOptions': { debuggerAddress: 'localhost:2431' }, networkConnectionEnabled: false, pageLoadStrategy: 'normal', platformName: 'windows', proxy: {}, setWindowRect: true, strictFileInteractability: false, timeouts: { implicit: 0, pageLoad: 300000, script: 30000 }, unhandledPromptBehavior: 'dismiss and notify', 'webauthn:extension:largeBlob': true, 'webauthn:virtualAuthenticators': true, 'webdriver.remote.sessionid': 'd6d47bd3f2c0d3e00397110368cb64ef8737aea0' }, sessionId: 'd6d47bd3f2c0d3e00397110368cb64ef8737aea0', i Connected to hub-cloud.browserstack.com on port 80 (3904ms). Using: chrome (89.0.4389.90) on windows platform. Received session with ID: d6d47bd3f2c0d3e00397110368cb64ef8737aea0 **The end of the log** Error while running .locateMultipleElements() protocol action: invalid selector – invalid selector: Unable to locate an element with the xpath expression #textField_name because of the following error: Request POST http://hub-cloud.browserstack.com /wd/hub/session/d6d47bd3f2c0d3e00397110368cb64ef8737aea0/elements { using: 'xpath', value: '#textField_name' } Response 400 POST http://hub-cloud.browserstack.com/wd/hub/session/d6d47bd3f2c0d3e00397110368cb64ef8737aea0/elements (140ms) { value: { error: 'invalid selector', message: 'invalid selector: Unable to locate an element with the xpath expression #textField_name because of the following error:\nSyntaxError: Failed to execute \'evaluate\' on \'Document\': The string \'#text Field_name\' is not a valid XPath expression.\n (Session info: chrome=89.0.4389.90)', stacktrace: '' }, sessionId: 'd66071372242e5767e7be0e99a751452', status: 32 } Error while running .locateMultipleElements() protocol action: invalid selector – invalid selector: Unable to locate an element with the xpath expression #textField_name because of the following error: Timed out while waiting for element <#textField_name> to be present for 12000 milliseconds. - expected "visible" but got: "not found" (12055ms) undefined → Completed command: waitForElementVisible ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout, retryInterval, messag e}) (12055ms) Request GET http://hub-cloud.browserstack.com /wd/hub/session/d6d47bd3f2c0d3e00397110368cb64ef8737aea0/screenshot → Completed command: waitAndClick ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout, retryInterval, message}) (12677ms) Response 200 GET http://hub-cloud.browserstack.com/wd/hub/session/d6d47bd3f2c0d3e00397110368cb64ef8737aea0/screenshot (565ms) { value: '', sessionId: 'd66071372242e5767e7be0e99a751452', status: 0, suppressBase64Data: true } VError: an AfterAll hook errored, process exiting: cucumber.conf.js:163: Error while running "waitAndClick" command: Timed out while waiting for element <#textField_name> to be present for 12000 milliseconds. - expected "visible" but got: "not found" (12055ms) at _bluebird.default.each (..\cucumber\lib\runtime\index.js:60:15) caused by: Error while running "waitAndClick" command: Timed out while waiting for element <#textField_name> to be present for 12000 milliseconds. - expected "visible" but got: "not found" (12055ms) at Object.command (.../commands/waitAndClick.js:12:20) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! automationTests@1.0.0 test: `mkdirp report && cucumber-js --require-module babel-core/register --require cucumber.conf.js endToEndTests/features --require endToEndTests/step_definitions --format node_m odules/cucumber-teamcity-formatter --format json:report/cucumber_report.json "--tags" "@tagOfTheTest" "--format" "node_modules/cucumber-pretty"` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the automationTests@1.0.0 test script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. ```txt Error while running .locateMultipleElements() protocol action: The supplied argument was an invalid selector (e.g. XPath/CSS). – invalid selector: Unable to locate an element with the... --> ```
Configuration
nightwatch.json
```js ```
Your Environment
nightwatch --version
nightwatch-api --version
yarn --version
node --version