Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 13:27
    inexiav commented #3401
  • 13:27
    inexiav commented #3401
  • 12:01
    vaibhavsingh97 synchronize #3316
  • 12:01
    vaibhavsingh97 synchronize #3316
  • 12:00
    vaibhavsingh97 synchronize #3316
  • 12:00
    vaibhavsingh97 synchronize #3316
  • 11:57
    vaibhavsingh97 assigned #3409
  • 11:57
    vaibhavsingh97 assigned #3409
  • 11:48
    vaibhavsingh97 opened #3411
  • 11:48
    vaibhavsingh97 opened #3411
  • 11:41

    gravityvi on main

    fix test for browserstack trans… (compare)

  • 11:41

    gravityvi on main

    fix test for browserstack trans… (compare)

  • 11:41
    gravityvi closed #3394
  • 11:41
    gravityvi closed #3394
  • 11:36
    swrdfish review_requested #3394
  • 11:36
    swrdfish review_requested #3394
  • 11:36
    swrdfish synchronize #3394
  • 11:36
    swrdfish synchronize #3394
  • 10:22
    suraj007118 commented #3410
  • 10:22
    suraj007118 commented #3410
Andrei Rusu
@beatfactor
Hey everyone! Nightwatch v1.7.3 is released in NPM. You can check out the changelog here:
https://github.com/nightwatchjs/nightwatch/releases/tag/v1.7.3
Andrei Rusu
@beatfactor
We released a survey where you can let us know about what features you'd like to see in Nightwatch v2. Here's the link: https://forms.gle/zBhbjdsDE77hTHSB7
neu5
@neu5
hey, If I expose some global methods eg. window.e2e
how can I access them in the test?
I want to write API for testing
Ravi Sawlani
@gravityvi
Hey @neu5, I didn't get your use case quite clearly. would it be possible to elaborate it or maybe share a code snippet?
neu5
@neu5

hey @gravityvi, my application renders in <canvas> so I cannot interact with it via DOM elements. So my idea was to create global object on window, eg. e2e holding methods eg.
e2e: { doSmth() }
that method under the hoods can call the backend endpoint or whatever. I'm trying to have tests looking like

client
      .url("http://localhost:5000/")
      .makePlayerDie('playerName')
      .pause(2000) // wait for backend to perform
      .checkIfPlayerIsDead('playerName')
      .respawnPlayer('playerName')
      .checkIfPlayerIsAlive('playerName')
      .end()

this makePlayerDie, checkIfPlayerIsDead, respawnPlayer, checkIfPlayerIsAlive are methods available in
window.e2e global
but I don't know how to access this global from the nightwatch

neu5
@neu5
okey, it looks like I am on the right path. I need to use execute :)
Ravi Sawlani
@gravityvi
πŸ˜ƒ
Tim Yao
@tim-yao
Hi, I have problem to use basic authentication in Safari. Url like "https://user:pass@hostname.com" works for Chrome and Firefox, but won't work for Safari. Do we have a solution except proxy?
Ravi Sawlani
@gravityvi
Hi @tim-yao, can you share your nightwatch config?
Tim Yao
@tim-yao
@gravityvi I mean just browser.url("https://user:pass@hostname.com"); won't work for Safari.
Safari in MacOS does not support basic authentication by passing the username and password in URL. Unfortunately, currently we do not have any workaround to solve this problem.
Looks like no solution for it based on this doc about selenium:
https://www.browserstack.com/docs/automate/selenium/basic-http-authentication#pass-username-and-password-in-the-url
dharls36
@dharls36

Hi.

I've just installed the latest Nightwatch (npm node package) version 1.7.7 and the way I run my tests is no longer working.

If I run my tests on a group basis:

npx nightwatch -c config/local.conf.js -e chrome --g carInsurance

it works ok.

However, if I run them on a tag basis:

npx nightwatch -c config/local.conf.js -e chrome --t carInsuranceTest

it runs all of my tests, not just the tests with the carInsuranceTest tag.

Has the way you run tests using tags changed in the latest Nightwatch version (my tests worked Ok in my previous nightwatch version, which was 0.9.21)?

Any help would be greatly appreciated. Thanks.

Ravi Sawlani
@gravityvi
Hey @dharls36, I am not able to reproduce the issue. Can you share your project structure and nightwatch config?
dharls36
@dharls36

Hi.
Ok, so this appeared to be an issue with my nightwatch 1.7.7 setup, as it works locally with 1.7.6.
However, something strange is happening with 1.7.6 when I run my tests through Browserstack. If I run a single test, it works Ok. However, if I run the same test but using its tag, it falls.

darrenharley@wks63613 Functional % ./node_modules/.bin/nightwatch -c config/browserstack.conf.js -e chrome /Users/darrenharley/Documents/Git/uk-content-parkers/Tests/Functional/tests/carInsurance/PAR-4540.js
Using insecure HTTP connection on port 80. Consider using SSL by setting port to 443 in your Nightwatch configuration.
β„Ή Connected to hub-cloud.browserstack.com on port 80 (5875ms).
  Using: chrome (85.0.4183.83) on WINDOWS platform.

βœ” [Car Insurance/ PAR 4540] navigate to an example model insurance groups page (4.614s)
βœ” [Car Insurance/ PAR 4540] choose another car dropdowns removed (146ms)
βœ” [Car Insurance/ PAR 4540] insurance group link correctly added (915ms)
βœ” [Car Insurance/ PAR 4540] closing the browser (1.644s)

  See more info, video, & screenshots on Browserstack:
  https://automate.browserstack.com/builds/8f4a93d294271b7c0e7b8db31370f34dd7ba1e76/sessions/ebdae3948c7f16175783f9f814b7aadc21e91c02

OK. 4  total assertions passed (13.513s)

darrenharley@wks63613 Functional % ./node_modules/.bin/nightwatch -c config/browserstack.conf.js -e chrome --tag carInsurance                                                           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...
_________________________________________________

TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (788ms)

  Error: Handshake failed: no matching key exchange algorithm
       at addChunk (internal/streams/readable.js:309:12)
       at readableAddChunk (internal/streams/readable.js:284:9)
       at Socket.Readable.push (internal/streams/readable.js:223:10)
       at TCP.onStreamRead (internal/stream_base_commons.js:188:23)

Has anyone seen this before? Thanks.

--group works ok too. So it appears to be just tags.
Ravi Sawlani
@gravityvi
@dharls36 can you share your browserstack.conf.js? I am not able to reproduce this in version 1.7.6
dharls36
@dharls36

Hi @gravityvi yeah, sure. Here it is...

browserstackConf = {
    src_folders: [
        'tests/'
    ],
    output_folder: false,
    globals_path: 'globals.js',
    page_objects_path: 'config/page_objects',
    test_workers: true,
    detailed_output: false,
    output: true,
    disable_error_log: true,
    disable_colors: false,
    custom_commands_path: 'config/commands/',
    selenium: {
        start_process: false,
        host: 'hub-cloud.browserstack.com',
        port: 80
    },
    test_settings: {
        default: {
            launch_url: 'https://www.parkers.co.uk/',
            desiredCapabilities: {
                project: 'Parkers',
                build: 'latestBuild',
                'browserstack.selenium_version': '3.141.59',
                'browserstack.user': 'xxxxxx',
                'browserstack.key': 'xxxxxx',
                'browserstack.local': false,
                'browserstack.debug': true,
                'excludeSwitches': ['disable-popup-blocking'],
            },
        },
    chrome: {
        desiredCapabilities: {
            os: 'Windows',
            os_version: '10',
            browserName: 'Chrome',
            browser_version: '85.0',
            javascriptEnabled : true,
            acceptSslCerts: true,
            acceptInscureCerts: true,
            chromeOptions : {
                'excludeSwitches': ['disable-popup-blocking'],
                args: [
                    '--ignore-certificate-errors',
                    '--disable-web-security',
                    '--window-size=1920,1080',
                    '--disable-extensions',
                    '--start-maximized',
                    '--disable-dev-shm-usage',
                    'disable-infobars',
                    'disable-popup-blocking',
                    'disable-notifications',
                    '--log-level=3'],
                prefs: {
                    'profile.managed_default_content_settings.popups' : 1,
                    'profile.managed_default_content_settings.notifications' : 1
                },
            },
        },
    },
    safari: {
        desiredCapabilities: {
            os: 'OS X',
            os_version: 'Catalina',
            browserName: 'Safari',
            browser_version: '13.1'
        },
    },
    edge: {
        desiredCapabilities: {
            os: 'Windows',
            os_version: '10',
            browserName: 'Edge',
            browser_version: '18.0'
        },
    },
    firefox: {
        desiredCapabilities: {
            os: 'OS X',
            os_version: 'Catalina',
            browserName: 'Firefox',
            browser_version: '76'
        },
    },
    android: {
        desiredCapabilities: {
            device: 'Google Pixel 2',
            os_version: '8.0',
            realMobile: 'true'
        },
    },
  },
};

for (const settingsLoop in browserstackConf.test_settings) {
    const config = browserstackConf.test_settings[settingsLoop];
    config["selenium_host"] = browserstackConf.selenium.host;
    config["selenium_port"] = browserstackConf.selenium.port;
    config["desiredCapabilities"] = config["desiredCapabilities"] || {}
    for (const capabilitiesLoop in browserstackConf.common_capabilities) {
    config["desiredCapabilities"][capabilitiesLoop] = config["desiredCapabilities"][capabilitiesLoop] || browserstackConf.common_capabilities[capabilitiesLoop]
    }
}

module.exports = browserstackConf

many thanks :)

Ravi Sawlani
@gravityvi
@dharls36 I used this config with Nightwatch version 1.7.6, I am afraid I am not able to reproduce it. Could you a setup a small test recreating this issue so I can pick up from there?
personwyr
@personwyr
Why is browser.mouseButtonClick ('right ') a left click instead of a right click
I'm Chinese. I'm sorry for my poor English
Ravi Sawlani
@gravityvi
Hey @personwyr, I tried re-creating this issue in a sample test. The right click worked fine. Can you share some code snippet where I can re-create this? By the way your English looks alright to me :smile:
personwyr
@personwyr
// @gravityvi
// A tab navigation DOM that can pop up a drop-down box with the right click
const tab = '/html/body/div[1]'  

module.exports = {
  'ι‘΅ι’εˆ·ζ–°': (brower) => {
    brower
      .useXpath()
      .moveToElement(tab)
      .mouseButtonClick('right')
      .pause(5000)
  }
}
personwyr
@personwyr
moveToElement(tab, 5, 5)
I just sent a wrong code
Ravi Sawlani
@gravityvi
which page has been used to for this sample test?
personwyr
@personwyr

@gravityvi

module.exports = {
    'contextmenu test': function (browser) {
      browser
        .url('https://panjiachen.github.io/vue-element-admin/#/login')
        .waitForElementVisible('body', 1000)
        .click('#app > div > form > button')
        .pause(1000)
        .click('#app > div > div.sidebar-container > div > div.scrollbar-wrapper.el-scrollbar__wrap > div > ul > div:nth-child(2) > a')
        .pause(2000)
        .moveToElement('#tags-view-container > div > div.el-scrollbar__wrap > div > span:nth-child(1)', 5, 5)
        .mouseButtonClick('right')
        .pause(6000)
    }
}

is this ok?
I executed this code and didn't get the expected effect πŸ‘€

Ravi Sawlani
@gravityvi
Yes this works. I get a dropdown at the end of the test with 3 options refresh close others and close all. @personwyr is this what you were expecting from the test?
personwyr
@personwyr
Yes, I expect the first tab to get a dropdown with 3 options.
But on my computer, the first tab was selected without dropdown.
I use Nightwatch 1.7.6
Ravi Sawlani
@gravityvi
which browser are you using to run the test can you also share your nightwatch config so I verify it?
personwyr
@personwyr

nightwatch.conf.js

module.exports = {
  src_folders: ['tests'],
  output_folder: 'output',
  custom_assertions_path: [],
  page_objects_path: '',
  globals_path: '',
  selenium: {
      start_process: true,
      server_path: require('selenium-server').path,
      host: '127.0.0.1',
      port: 5555,
      cli_args: {
          'webdriver.chrome.driver': require('chromedriver').path
      }
  },
  test_settings: {
      default: {
          selenium_port: 5555,
          selenium_host: 'localhost',
          silent: true,
          globals: {
              devServerURL: 'http://localhost:' + (process.env.PORT || 1111)
          }
      },
      chrome: {
          desiredCapabilities: {
              browserName: 'chrome',
              javascriptEnabled: true,
              acceptSslCerts: true
          }
      },
      firefox: {
          desiredCapabilities: {
              browserName: 'firefox',
              javascriptEnabled: true,
              acceptSslCerts: true
          }
      }
  }
}

I'm using chrome

My dependencies version:
"chromedriver": "^91.0.1",
"nightwatch": "^1.7.7",
"selenium-server": "^3.141.59"
Ravi Sawlani
@gravityvi
is it possible to use default nightwatch config?
personwyr
@personwyr
ok, i'll try. I see an example "https://github.com/nightwatchjs/nightwatch-website-test".
I'll re-create the project tomorrow. At present, it may be caused by nightwatch config. Thank you
personwyr
@personwyr
I used the default nightwatch config, The problem is solved πŸ‘πŸ˜Š
Ravi Sawlani
@gravityvi
πŸŽ‰
Henry Pitman
@profplum700
image.png
Hi, we're trying to upgrade from Nightwatch 1.2.4 to 1.7.7. We get several errors still though! Does anyone have any tips for troubleshooting/resolving?
This is our package.json
image.png
Amit Pandey
@mastergogo
is there any way to run tests in mobile emulation (toggle device toolbar) in chrome for any web page?
Amit Pandey
@mastergogo
found it, updated my config with below:
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled : true,
acceptSslCerts : true,
chromeOptions: {mobileEmulation: {
deviceMetrics: {width: 360, height: 640, pixelRatio: 3},
userAgent:
'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/60.0.3112.101 Mobile Safari/537.36 profi-autotest',
}
}
Tim Yao
@tim-yao
Hi, in VSCode we can use F12 to find the definition of a function. However, it seems not work for nightwatch commands. Either my custom commands or core commands. Does anyone here has solution for it?
I think this https://www.npmjs.com/package/@types/nightwatch will help but couldn't make it work. Based on https://code.visualstudio.com/docs/nodejs/working-with-javascript#_typings-and-automatic-type-acquisition
Thanks.
Amit Pandey
@mastergogo
Hi, working on testing the mobile app using the ionic framework, it has custom HTML elements (ion-button) and UI components, when I'm trying to click a button, it says the button is not visible and not interactable, I tried using XPath and CSS selectors both also delaying the click by few seconds, but unable to click on the button, can anyone help or point me in the right direction? thanks in advance
strellisrx
@strellisrx
Hey everyone I'm new on gitter. I'll appreciate some insight on this issue. I looked all over the internet and still haven't found a definitive solution to this issue.
When running npm run cuke I get:
'Driver info: driver.version: unknown'
],
message: 'Unable to create session from {'
},
status: 33
It does log the version prior to executing
And I can create a session if I do it from the hub manually
I'm using chromeversion90 macOS big sur
this is my nightwatch conf

// @ts-ignore

const chromedriver = require('chromedriver');
const seleniumServer = require('selenium-server');

const config = {
// we use a nightwatch.conf.js file so we can include comments and helper functions
src_folders: [
'src/tests/functionaltest', // we use '/test' as the name of our test directory by default. So 'test/e2e' for 'e2e'.
],
page_objects_path: 'src/tests/page-objects',
output_folder: './node_modules/nightwatch/reports', // reports (test outcome) output by Nightwatch
custom_commands_path: 'src/tests/commands',
selenium: {
start_process: true,
server_path: seleniumServer.path,
log_path: '',
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': chromedriver.path,
},
},
test_workers: { enabled: true, workers: 'auto' }, // perform tests in parallel where possible
test_settings: {
default: {
webdriver: {
start_process: true,
server_path: chromedriver.path,
port: 4444,
cli_args: ['--port=4444'],
},
launch_url: 'http://localhost:3000',
selenium_port: 4444,
selenium_host: '127.0.0.1',
silent: true,
capabilities: {
configuration: {
_comment: 'Configuration for Node',
cleanUpCycle: 2000,
timeout: 30000,
port: 5555,
host: '127.0.0.1',
register: true,
hubPort: 4444,
maxSession: 5,
},
},
desiredCapabilities: {
browserName: 'chrome',
seleniumProtocol: 'WebDriver',
chromeOptions: {
w3c: false,
args: [
'--enable-features=NetworkService,NetworkServiceInProcess',
'--headless',
'--disable-gpu',
'--no-sandbox',
'--disable-dev-shm-usage',
'--window-size=1920,1080',
],
},
},
screenshots: {
enabled: true,
path: './reports/nightwatchTests/screenshots',
on_failure: true,
on_error: true,
},
use_xpath: false,
},
local: {
launch_url: 'http://localhost:3000',
selenium_port: 4444,
selenium_host: '127.0.0.1',
silent: true,
globals: {
waitForConditionTimeout: 15000, // Default timeout, 15 seconds
},
desiredCapabilities: {
browserName: 'chrome',
platform: 'ANY',
seleniumProtocol: 'WebDriver',
chromeOptions: {
w3c: false,
args: [
'--enable-features=NetworkService,NetworkServiceInProcess',
'--headless',
'--disable-gpu',
'--no-sandbox',
'--disable-dev-shm-usage',
'--window-size=1920,1080',
],
},
javascriptEnabled: true,
acceptSslCerts: true,
},
},

Ravi Sawlani
@gravityvi
Hey @strellisrx, can you use compose mode for sharing code as it would more readable also can you share your cuke npm script you are trying to run?
Xander Dumaine
@xdumaine

Hi, I'm trying to convert a bash script that invokes nightwatch to using programmatic API, and when I'm running it, the webdriver isn't starting and I can't figure out why.

config:

{
  output_folder: 'nightwatch_output',
  webdriver: {
    start_process: true,
    port: 9515,
    server_path: '/usr/local/bin/chromedriver',
    cli_args: [
      '--port=9515',
      '--log-path=nightwatch_output/chromedriver-2021-07-23T00:55:10.479Z.log'
    ]
  },
  test_settings: {
    default: {
      desiredCapabilities: [Object],
      globals: [Object],
      launch_url: 'redacted',
      screenshots: [Object]
    }
  },
  globals: {
    asyncHookTimeout: 90000,
    retryAssertionTimeout: 30000,
    waitForConditionTimeout: 30000
  },
  src_folders: [ 'test' ]
}

Code:

(async () => {
  const runner = Nightwatch.CliRunner();
  await runner.setup(config).startWebDriver();

  try {
    runner.runTests();
  } catch (err) {
    await runner.stopWebDriver();
  }
})();

output:


==========================
β ‹ Connecting to localhost on port 9515...
    POST  /session - ECONNREFUSED
⚠ Error connecting to localhost on port 9515.
_________________________________________________

TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (123ms)

   Error: An error occurred while retrieving a new session: "Connection refused to 127.0.0.1:9515". If the Webdriver/Selenium service is managed by Nightwatch, check if "start_process" is set to "true".