How to use saucelabs with nightwatch? - nightwatch.js

I have the following configuration in my nightwatch.json file
"saucelabsChrome": {
"selenium_host": "ondemand.saucelabs.com",
"selenium_port": 80,
"username": "example",
"access_key": "--REDACTED---",
"desiredCapabilities": {
"acceptsSslCerts": true,
"name": "chrome",
"browserName": "chrome",
"platform": "OS X 10.11",
"version": "45.0"
}
},
However, when I run nightwatch with sauce labs
node nightwatch ---args '{"beta": "true", "env": "stage"}' --test tests/example.js -e saucelabsChrome
I get an error
Couldn't find element signUpAdobe
Two questions
Where can I see the nightwatch command running on Saucelabs?
What is the best way to integrate saucelabs with nightwatch?

Here is an example of my nightwatch.json file configured to run parallel tests on Sauce Labs.
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "custom_commands",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"selenium" : {
"start_process" : false,
"server_path" : "",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.ie.driver" : ""
}
},
"test_workers" : {"enabled" : true, "workers" : "auto"},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 80,
"selenium_host" : "ondemand.saucelabs.com",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"username" : "${SAUCE_USERNAME}",
"access_key" : "${SAUCE_ACCESS_KEY}",
"desiredCapabilities": {
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"chrome": {
"desiredCapabilities": {
"platform": "XP",
"browserName": "chrome",
"version": "41"
}
},
"firefox" : {
"desiredCapabilities": {
"platform": "XP",
"browserName": "firefox",
"version": "33"
}
},
"internet_explorer_10" : {
"desiredCapabilities": {
"platform": "Windows 7",
"browserName": "internet explorer",
"version": "10"
}
}
}
}
Here is a link to the entire project if you would like to take a look:
https://github.com/saucelabs-sample-test-frameworks/JS-Nightwatch.js
As to your second question. You can see the tests running in the Sauce Labs dashboard. Login at www.saucelabs.com and click on the tests tab in the top left corner.

I realize it's been a few years, but when I was searching I came across this post and found a newer guide for how to use SauceLabs with Nightwatch
Hopefully this helps anyone ending up here like I did :D

Related

How to launch Windows Terminal with Multiple Tabs?

I am attempting to use startupActions to launch a second tab when Windows Terminal launches with no luck.
My default shell is WSL, so I have the following in my settings.json:
"startupActions": "; new-tab -p PowerShell",
I've tried it without the semi-colon and without the -p flag as well.
Here is the settings.json minus the color schemes:
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command":
{
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c"
},
{
"command": "paste",
"keys": "ctrl+v"
},
{
"command": "find",
"keys": "ctrl+shift+f"
},
{
"command":
{
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
}
],
"centerOnLaunch": true,
"copyFormatting": "none",
"copyOnSelect": false,
"defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"initialCols": 98,
"initialRows": 24,
"showTerminalTitleInTitlebar": false,
"startupActions": "; new-tab -p PowerShell",
"useAcrylicInTabRow": true,
"profiles":
{
"defaults":
{
"colorScheme": "Dracula",
"cursorShape": "filledBox",
"elevate": true,
"font":
{
"face": "MesloLGS NF",
"size": 12
},
"startingDirectory": null
},
"list":
[
{
"antialiasingMode": "cleartype",
"experimental.retroTerminalEffect": false,
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"hidden": false,
"name": "Command Prompt",
"opacity": 75,
"useAcrylic": true
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": true,
"name": "Azure Cloud Shell",
"opacity": 75,
"source": "Windows.Terminal.Azure",
"useAcrylic": true
},
{
"antialiasingMode": "cleartype",
"experimental.retroTerminalEffect": false,
"font":
{
"size": 12
},
"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"hidden": false,
"name": "Ubuntu",
"opacity": 75,
"scrollbarState": "visible",
"source": "Windows.Terminal.Wsl",
"startingDirectory": "\\\\wsl$\\Ubuntu\\home\\steve",
"suppressApplicationTitle": true,
"tabColor": "#BD93F9",
"tabTitle": "Ubuntu 20.04",
"useAcrylic": true
},
{
"antialiasingMode": "cleartype",
"experimental.retroTerminalEffect": false,
"font":
{
"face": "Fira Code Retina"
},
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell",
"opacity": 75,
"source": "Windows.Terminal.PowershellCore",
"tabColor": "#6272A4",
"useAcrylic": true
}
]
}
}
"elevate": true is your culprit here. You can't have mixed-elevation of tabs in the same window. Admin and non-admin windows need to stay separate. So when you launch those startupActions, the Terminal automatically creates a new admin window to host the powershell tab (which you've set to always run as admin).
Removing that setting from your powershell profile should work.

Nightwatch parallel for two browser run only default for browserstack

I have configured several test settings and I want to run parallel chrome and ie.
When I run
./node_modules/.bin/nightwatch --env chrome
test for chrome runs
./node_modules/.bin/nightwatch --env ie
test for ie runs
./node_modules/.bin/nightwatch --env ie,chrome
test for firefox runs (as I guess this run only default ones and nothing more)
Nightwatch 1.0.18
{
"src_folders": [
"test"
],
"output_folder": "reports",
"live_output" : true,
"custom_commands_path": "config/commands",
"test_runner": {
"type" : "mocha",
"options" : {
"grep": "#acc"
}
},
"test_settings": {
"default": {
"selenium_host": "hub-cloud.browserstack.com",
"selenium_port": 80,
"launch_url": "localhost",
"browserstack.key": "KEY",
"browserstack.user": "USER",
"browserstack.local": "true"
},
"chrome-local": {
"default_path_prefix": "",
"launch_url": "localhost",
"screenshots": {
"enabled": true,
"on_failure": true,
"on_success": true,
"on_error": true,
"path": "./screenshots"
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"chromeOptions": {
"args": [
"--no-sandbox",
"headless",
"window-size=1920,1200"
]
},
"acceptSslCerts": true,
"acceptInsecureCerts": true,
"elementScrollBehavior": 1
}
},
"chrome": {
"desiredCapabilities": {
"browser": "chrome"
}
},
"ie": {
"desiredCapabilities": {
"browserName": "ie",
}
}
}
}
for running parallel tests using Nightwatch refer - https://github.com/browserstack/nightwatch-browserstack
As you need to run parallel tests on Chrome and IE browsers you need to make changes to the line https://github.com/browserstack/nightwatch-browserstack/blob/master/package.json#L10 as follows-
"parallel": "./node_modules/.bin/nightwatch -c conf/parallel.conf.js
-e ie,chrome"

Nightwatch.js: why do I get Unable to create new service: GeckoDriverService?

I am trying to setup the latest nightwatch.js for the first time. This is my nightwatch.json:
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"selenium" : {
"start_process" : true,
"server_path" : "selenium-server-standalone-3.8.1.jar",
"log_path" : "",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.gecko.driver" : "",
"webdriver.edge.driver" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "firefox",
"marionette": true
}
},
"chrome" : {
"desiredCapabilities": {
"browserName": "chrome"
}
},
"edge" : {
"desiredCapabilities": {
"browserName": "MicrosoftEdge"
}
}
}
}
When I run nightwatch I get this error:
Starting selenium server... started - PID: 3176
[Go] Test Suite
===================
Running: Demo test
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ value:
{ message: 'Unable to create new service: GeckoDriverService\nBuild info: ve
sion: \'3.8.1\', revision: \'6e95a6684b\', time: \'2017-12-01T19:05:32.194Z\'\n
ystem info: host: \'S0026COW1983\', ip: \'10.39.13.81\', os.name: \'Windows Ser
er 2008 R2\', os.arch: \'x86\', os.version: \'6.1\', java.version: \'1.8.0_131\
\nDriver info: driver.version: unknown',
error: 'session not created' },
How can I resolve this?
I will assume that you are launching the default test settings which will try to access geckoDriver.
Looks like you haven't specified the paths for your drivers, "webdriver.chrome.driver" : "", "webdriver.gecko.driver" : "", "webdriver.edge.driver" : ""
You need to point those to your driver executables, e.g. from my project:
'webdriver.gecko.driver':'/.selenium/geckodriver/0.19.0-x64-geckodriver'

Selenium 3.7.1 webdriver Error: Timed out waiting for driver server to start. Windows only

I have the following error on Windows 7 but not a a mac. It is started by nightwatch. Any ideas?
Starting selenium server... started - PID: 17228
[Test] Test Suite
=============================
Running: TestWithSettingSearchValue
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ value:
{ stacktrace: 'org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.\nBuild info: version: \'3.7.1\', revision: \'8a0099a\', time: \'2017-11-06T21:07:36.161Z\'\nSystem info: host: \'W7D0596\', ip: \'172.21.1.54\', os.name: \'Windows 7\', os.arch: \'amd64\', os.version: \'6.1\', java.version: \'1.8.0_91\'\nDriver info: driver.version: unknown\r\n\tat org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:192)\r\n\tat org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178)\r\n\tat org.openqa.selenium.remote.server.ServicedSession$Factory.apply(ServicedSession.java:207)\r\n\tat org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$apply$11(ActiveSessionFactory.java:167)\r\n\tat
Our package.json
{
"name": "nightwatch",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"test": "tests"
},
"scripts": {
"test": "nightwatch"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"chromedriver": "^2.33.2",
"nightwatch": "^0.9.16",
"selenium-server-standalone-jar": "^3.7.1"
}
}
nightwatch:
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"selenium" : {
"start_process" : true,
"server_path" : "./node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.7.1.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "./node_modules/chromedriver/bin/chromedriver",
"webdriver.ie.driver" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://127.0.0.1:3000/",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
You have to use the file extension for it to work on windows. Update your config and add .exe to the chromedriver path and it should start working.
"cli_args" : {
"webdriver.chrome.driver" : "./node_modules/chromedriver/lib/chromedriver/chromedriver.exe"
}

Parse Server S3 file adapter not working

I have been trying to set up S3 File Adapter with no luck. I am starting Parse Server usingPM2 and this is my ecosystem.json file:
"apps" : [{
"name" : "parse-wrapper",
"script" : "/usr/bin/parse-server",
"watch" : true,
"merge_logs" : true,
"cwd" : "/home/parse",
"env": {
"PARSE_SERVER_CLOUD_CODE_MAIN": "/home/parse/cloud/main.js",
"PARSE_SERVER_DATABASE_URI": "myuri",
"PARSE_SERVER_APPLICATION_ID": "myappid",
"PARSE_SERVER_MASTER_KEY": "my master key",
"PARSE_SERVER_JAVASCRIPT_KEY": "myjskey",
"PARSE_SERVER_FILES_ADAPTER": "parse-server-s3-adapter",
"S3_ACCESS_KEY": "MYS3ACCESSKEY",
"S3_SECRET_KEY": "MYS3SECRETKEY",
"S3_BUCKET": "thenameofmybucket"
}
}]
}
Any help will be greatly appreciated :)
Although this question is one year ago, I wish the solution could help others because i had also spent times to research about pm2 setup.
"env": {
"PARSE_SERVER_FILES_ADAPTER": {
"module": "parse-server-s3-adapter",
"options": {
"accessKey": "MYS3ACCESSKEY",
"secretKey": "MYS3SECRETKEY",
"bucket": "thenameofmybucket",
"region": "ap-southeast-1",
"bucketPrefix": "",
"directAccess": true,
"baseUrl": null,
"baseUrlDirect": false,
"signatureVersion": "v4",
"globalCacheControl": null,
"ServerSideEncryption": "AES256|aws:kms"
}
}
you might revise the value of accessKey, secretKey, bucket and region

Resources