nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.78k stars 1.31k forks source link

WaitForElementPresent error when element doesn't exist -> Bluetooth: bluetooth_adapter_winrt.cc:1075 Getting Default Adapter failed. #3142

Closed reallymello closed 1 year ago

reallymello commented 2 years ago

Describe the bug

When using .waitForElementPresent and the element does not exist in the DOM I get the following error in the output log

[22184:13332:0409/200244.007:ERROR:device_event_log_impl.cc(214)] [20:02:44.008] Bluetooth: bluetooth_adapter_winrt.cc:1075 Getting Default Adapter failed.

Outside of the strange error the rest of the test appears to execute and report the correct assertion failures.

Sample test

sampleTest.js

```js "Create a problem": () => { browser.url("https://www.google.com").waitForElementPresent("#doesntExist"); } ```

Run with command

$ nightwatch --verbose --env chrome

Verbose output

debug.log

```txt Running Create a problem: ──────────────────────────────────────────────────────────────────────────────────────────────────── → Running [beforeEach]: → Completed [beforeEach]. → Running command: url ('https://www.google.com') ⠋ Loading url: https://www.google.com Request POST /session/c3213e405eecb651b5706677d30f1a0d/url ⠹ Loading url: https://www.google.com Response 200 POST /session/c3213e405eecb651b5706677d30f1a0d/url (3014ms) ℹ Loaded url https://www.google.com in 3017ms → Completed command: url ('https://www.google.com') (3020ms) → Running command: waitForElementPresent ('#doesntExist') Request POST /session/c3213e405eecb651b5706677d30f1a0d/elements { using: 'css selector', value: '#doesntExist' } Response 200 POST /session/c3213e405eecb651b5706677d30f1a0d/elements (11ms) { value: [] } Request POST /session/c3213e405eecb651b5706677d30f1a0d/elements { using: 'css selector', value: '#doesntExist' } Response 200 POST /session/c3213e405eecb651b5706677d30f1a0d/elements (6ms) { value: [] } [22184:13332:0409/200244.007:ERROR:device_event_log_impl.cc(214)] [20:02:44.008] Bluetooth: bluetooth_adapter_winrt.cc:1075 Getting Default Adapter failed. Request POST /session/c3213e405eecb651b5706677d30f1a0d/elements { using: 'css selector', value: '#doesntExist' } Response 200 POST /session/c3213e405eecb651b5706677d30f1a0d/elements (8ms) { value: [] } Request POST /session/c3213e405eecb651b5706677d30f1a0d/elements { using: 'css selector', value: '#doesntExist' } Response 200 POST /session/c3213e405eecb651b5706677d30f1a0d/elements (23ms) { value: [] } Request POST /session/c3213e405eecb651b5706677d30f1a0d/elements { using: 'css selector', value: '#doesntExist' } Response 200 POST /session/c3213e405eecb651b5706677d30f1a0d/elements (7ms) { value: [] } Request POST /session/c3213e405eecb651b5706677d30f1a0d/elements { using: 'css selector', value: '#doesntExist' } Response 200 POST /session/c3213e405eecb651b5706677d30f1a0d/elements (7ms) { value: [] } Request POST /session/c3213e405eecb651b5706677d30f1a0d/elements { using: 'css selector', value: '#doesntExist' } Response 200 POST /session/c3213e405eecb651b5706677d30f1a0d/elements (7ms) { value: [] } Request POST /session/c3213e405eecb651b5706677d30f1a0d/elements { using: 'css selector', value: '#doesntExist' } Response 200 POST /session/c3213e405eecb651b5706677d30f1a0d/elements (7ms) { value: [] } Request POST /session/c3213e405eecb651b5706677d30f1a0d/elements { using: 'css selector', value: '#doesntExist' } Response 200 POST /session/c3213e405eecb651b5706677d30f1a0d/elements (7ms) { value: [] } Request POST /session/c3213e405eecb651b5706677d30f1a0d/elements { using: 'css selector', value: '#doesntExist' } Response 200 POST /session/c3213e405eecb651b5706677d30f1a0d/elements (7ms) { value: [] } Request POST /session/c3213e405eecb651b5706677d30f1a0d/elements { using: 'css selector', value: '#doesntExist' } Response 200 POST /session/c3213e405eecb651b5706677d30f1a0d/elements (7ms) { value: [] } × Timed out while waiting for element <#doesntExist> to be present for 5000 milliseconds. - expected "found" but got: "not found" (5211ms) at Object.Create a problem (C:\Projects\nightwatchTutorials\typescriptExample\dist\test\helloWorld.js:19:47) → Completed command: waitForElementPresent ('#doesntExist') (5215ms) → Running [afterEach]: → Completed [afterEach]. FAILED: 1 assertions failed (8.241s) → Running [after]: → Completed [after]. → Running command: end () → Running command: session ('delete', [Function]) Request DELETE /session/c3213e405eecb651b5706677d30f1a0d Response 200 DELETE /session/c3213e405eecb651b5706677d30f1a0d (51ms) { value: null } → Completed command: end () (70ms) → Completed command: session ('delete', [Function]) (55ms) ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 17 | },*/ 18 | "Create a problem": () => { 19 | browser.url("https://www.google.com").waitForElementPresent("#doesntExist"); 20 | }, 21 | }; ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– × 1) helloWorld – Create a problem (8.241s) Timed out while waiting for element <#doesntExist> to be present for 5000 milliseconds. - expected "found" but got: "not found" (5211ms) at Object.Create a problem (C:\Projects\nightwatchTutorials\typescriptExample\dist\test\helloWorld.js:19:47) ```

Configuration

nightwatch.json

```js // // Refer to the online docs for more details: // https://nightwatchjs.org/gettingstarted/configuration/ // // _ _ _ _ _ _ _ // | \ | |(_) | | | | | | | | // | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__ // | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \ // | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | | // \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_| // __/ | // |___/ // module.exports = { // An array of folders (excluding subfolders) where your tests are located; // if this is not specified, the test source must be passed as the second argument to the test runner. src_folders: ['dist/test'], // See https://nightwatchjs.org/guide/working-with-page-objects/using-page-objects.html page_objects_path: ['dist/pages/'], // See https://nightwatchjs.org/guide/extending-nightwatch/custom-commands.html custom_commands_path: ['node_modules/nightwatch/examples/custom-commands/'], // See https://nightwatchjs.org/guide/extending-nightwatch/custom-assertions.html custom_assertions_path: '', // See https://nightwatchjs.org/guide/extending-nightwatch/plugin-api.html plugins: [], // See https://nightwatchjs.org/guide/#external-globals globals_path: '', webdriver: {}, test_settings: { default: { disable_error_log: false, launch_url: 'https://nightwatchjs.org', screenshots: { enabled: false, path: 'screens', on_failure: true }, desiredCapabilities: { browserName: 'firefox' }, webdriver: { start_process: true, server_path: '' } }, firefox: { desiredCapabilities: { browserName: 'firefox', alwaysMatch: { acceptInsecureCerts: true, 'moz:firefoxOptions': { args: [ // '-headless', // '-verbose' ] } } }, webdriver: { start_process: true, server_path: '', cli_args: [ // very verbose geckodriver logs // '-vv' ] } }, chrome: { desiredCapabilities: { browserName: 'chrome', 'goog:chromeOptions': { // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/ // // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78) w3c: true, args: [ //'--no-sandbox', //'--ignore-certificate-errors', //'--allow-insecure-localhost', //'--headless' ] } }, webdriver: { start_process: true, server_path: '', cli_args: [ // --verbose ] } }, edge: { desiredCapabilities: { browserName: 'MicrosoftEdge', 'ms:edgeOptions': { w3c: true, // More info on EdgeDriver: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options args: [ //'--headless' ] } }, webdriver: { start_process: true, // Download msedgedriver from https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/ // and set the location below: server_path: '', cli_args: [ // --verbose ] } }, ////////////////////////////////////////////////////////////////////////////////// // Configuration for when using cucumber-js (https://cucumber.io) | // | // It uses the bundled examples inside the nightwatch examples folder; feel free | // to adapt this to your own project needs | ////////////////////////////////////////////////////////////////////////////////// 'cucumber-js': { src_folders: ['examples/cucumber-js/features/step_definitions'], test_runner: { // set cucumber as the runner type: 'cucumber', // define cucumber specific options options: { //set the feature path feature_path: 'node_modules/nightwatch/examples/cucumber-js/*/*.feature', // start the webdriver session automatically (enabled by default) // auto_start_session: true // use parallel execution in Cucumber // parallel: 2 // set number of workers to use (can also be defined in the cli as --parallel 2 } } }, ////////////////////////////////////////////////////////////////////////////////// // Configuration for when using the browserstack.com cloud service | // | // Please set the username and access key by setting the environment variables: | // - BROWSERSTACK_USER | // - BROWSERSTACK_KEY | // .env files are supported | ////////////////////////////////////////////////////////////////////////////////// browserstack: { selenium: { host: 'hub-cloud.browserstack.com', port: 443 }, // More info on configuring capabilities can be found on: // https://www.browserstack.com/automate/capabilities?tag=selenium-4 desiredCapabilities: { 'bstack:options': { userName: '${BROWSERSTACK_USER}', accessKey: '${BROWSERSTACK_KEY}', } }, disable_error_log: true, webdriver: { timeout_options: { timeout: 15000, retry_attempts: 3 }, keep_alive: true, start_process: false } }, 'browserstack.local': { extends: 'browserstack', desiredCapabilities: { 'browserstack.local': true } }, 'browserstack.chrome': { extends: 'browserstack', desiredCapabilities: { browserName: 'chrome', chromeOptions: { w3c: true } } }, 'browserstack.firefox': { extends: 'browserstack', desiredCapabilities: { browserName: 'firefox' } }, 'browserstack.ie': { extends: 'browserstack', desiredCapabilities: { browserName: 'internet explorer', browserVersion: '11.0' } }, 'browserstack.safari': { extends: 'browserstack', desiredCapabilities: { browserName: 'safari' } }, 'browserstack.local_chrome': { extends: 'browserstack.local', desiredCapabilities: { browserName: 'chrome' } }, 'browserstack.local_firefox': { extends: 'browserstack.local', desiredCapabilities: { browserName: 'firefox' } }, ////////////////////////////////////////////////////////////////////////////////// // Configuration for when using the Selenium service, either locally or remote, | // like Selenium Grid | ////////////////////////////////////////////////////////////////////////////////// selenium_server: { // Selenium Server is running locally and is managed by Nightwatch // Install the NPM package @nightwatch/selenium-server or download the selenium server jar file from https://github.com/SeleniumHQ/selenium/releases/, e.g.: selenium-server-4.1.1.jar selenium: { start_process: true, port: 4444, server_path: '', // Leave empty if @nightwatch/selenium-server is installed command: 'standalone', // Selenium 4 only cli_args: { //'webdriver.gecko.driver': '', //'webdriver.chrome.driver': '' } }, webdriver: { start_process: false, default_path_prefix: '/wd/hub' } }, 'selenium.chrome': { extends: 'selenium_server', desiredCapabilities: { browserName: 'chrome', chromeOptions: { w3c: true } } }, 'selenium.firefox': { extends: 'selenium_server', desiredCapabilities: { browserName: 'firefox', 'moz:firefoxOptions': { args: [ // '-headless', // '-verbose' ] } } } } }; ```

Your Environment

Executable Version
nightwatch --version 2.0.10
npm --version 7.14.0
node --version v17.8.0
Browser driver Version
NAME VERSION
chromedriver 100.0.0
OS Version
NAME VERSION
Windows 10 19043.1586
gravityvi commented 2 years ago

Hey @reallymello, I tried the sample test using Nightwatch v2.1.0 I am not able to reproduce this.

reallymello commented 2 years ago

When using Windows and latest Chrome?

gravityvi commented 2 years ago

oh, I missed windows I will try using that.

AutomatedTester commented 1 year ago

@reallymello Does this still happen? The issue is coming from Chrome itself here.

AutomatedTester commented 1 year ago

Closing as this is chrome being overly verbose in it's output. Ideally Nightwatch shouldn't be affecting the logs coming out of Chrome as we might miss important info.