
in this lecture we are going to learn Nightwatch Js setUp , initially we will be starting things with Javascript then we will deep dive into typescript .
Install nightwatch and write your first test using exports, launching a URL, and clicking the sign in button with browser commands and mocha setup.
Discover how to write your first Nightwatch test case with Mocha as the runner in JavaScript, using describe blocks, input actions, assertions, and generating an HTML report in Chrome.
Configure and switch Nightwatch environments using the config file to run tests across QA, development, staging, and production in browsers like Chrome and Safari, with environment-specific base URLs.
Configure Nightwatch.js to continue tests after a failure by adjusting a flag, preventing test skips. Use rimraf to clean folders and manage failure screenshots for debugging.
This lecture updated on Nov23 2022
Learn how to locate multiple checkboxes with a common element selector in Nightwatch.js, iterate over the matched elements, and click each one reliably.
Master findElements in Nightwatch to locate multiple elements, retrieve text, and interact with checkboxes, leveraging the latest Nightwatch updates and Selenium-like element handling for web automation.
Master selecting options in Nightwatch by using select statements and robust selectors to interact with dropdowns, such as choosing OK, and validate resulting page behavior.
Learn how to upload a file in Nightwatch.js by using the upload file command with an absolute path and a selector, then click submit and observe the confirmation pop-up.
learn to obtain the count of elements using a common locator in nightwatch and perform operations by indexing and clicking on specific items based on the count.
Learn to use moveToElement in Nightwatch to interact with page elements and verify the count of matching elements using expect.
Master multiple windows handling in Nightwatch by using window commands to maximize or full screen, open new tabs and windows, and switch between handles with get all handles.
Here I see I have covered frames topic in typescript , so please check Nightwatch with typescript section and do watch this video to avoid confusion till I add another video tutorial on this in Javascript.
Here main intent is how we can switch to frames in webPage , you can identify frames in webpage by searching //iframe tag in the console. for finding indexes you just need to write (//iframe)[here goes the index] and search in console [don't forget if you find some frame at index two like (//iframe)[2] then in your code write browser.frame(1) because indexing starts from zero.
browser.frame(index|id|some web element that you can construct out of frame tag) is all you need to know for switching to frames .
for getting back to parent frame or out of frame just use browser.frameParent() or browser.frame(null)
In this video I will cover nightwatch reporting with mocha awesome & how to add logs to mocha reporting
Learn to add screenshots after each test step in Nightwatch.js using Mochawesome reports, capturing browser context and producing distinct screenshots for Facebook, Google, and YouTube steps to enhance reporting.
const addcontext = require("mochawesome/addContext");
describe('Facebook test', function () {
// test() and specify() is also available
it('amazon title test', function (browser) {
addcontext(this, "verifying the title ")
browser.assert.titleContains("Online Shopping site in India: Shop Online for Mobiles, Books, Watches, Shoes and More - Amazon.in")
});
it('amazon cart button test when no products', function (browser) {
addcontext(this, "verifying the cart button ")
browser.click('#nav-cart-text-container')
.assert.elementPresent("#nav-cart-text-container")
});
this.afterEach(function (browser, done) {
let path = process.cwd() + '/screenshots/' + Math.random().toString().substring(2, 5) + '.png'
browser.saveScreenshot(path)
addcontext(this, path)
done();
})
this.beforeEach(function (browser, done) {
addcontext(this, "navigating to amazon ")
browser.url(browser.launchUrl)
done();
})
});
reporterOptions:{
'code':false,
'charts':true,
'timestamp':true,
'reportPageTitle':'Automation Report',
'reportTitle':'Automation Sample Report'
}
pass "this" context from your tests to pages so that you can write logs for the code that u write in your pages as well. In page methods receive "this" context as (testCtx:Mocha.Context) . In order to use multiple it blocks use nightwatch 2.0 plus version
In this video we will talk about how to run tests in headless mode , do use resizeWindow(1600,900) method instead maximizeWindow() in headless mode. you can also use below desired capabilities in your config file in default env or which ever environment it might be rather specifying in command line so that it will run in headless mode.
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
args: ['headless','disable-gpu']
}
}
Learn to run Nightwatch tests in headless mode by passing headless options in the config. Compare headless versus headed execution and observe how tests run in different environments.
Hi Guys , in this video , we will group our tests and run them
Explore using globals in Nightwatch to share data across tests, and implement before and after hooks for setup and teardown, with global exports and promise handling via done callbacks.
Explore how to automate hovering and moving to elements with Nightwatch, using move to element, get element size, and x and y coordinates to interact with the resources popup.
Explore visual regression testing with Nightwatch by installing the visual regression plugin, configuring thresholds and baseline snapshots, and validating ui changes through screenshot comparisons.
Leverage lighthouse in nightwatch tests to measure page performance, generate audits, and report metrics like first contentful paint and performance scores for automated web testing.
Install the Nightwatch JS plugin via extensions, then run and debug tests directly from the testing icon, observe chrome launching, and use step over to execute test steps.
Configure the Nightwatch Tesults reporting plugin by adding the access token and enabling failure screenshots, then sign up, create a project and target, and view smart analysis results for bugs.
If you're someone who wants to learn mobile app automation as well using nightwatch, please visit the following url :
https://www.udemy.com/course/mobile-app-automation-using-nightwatch-and-appium/?referralCode=7ED7976F0826FD259254
Master how to use Nightwatch's browser.execute method to run JavaScript with CSS selectors, retrieve element text, handle errors, and interact with web pages through automated scripts.
Practice using browser.execute() with an XPath selector to click elements and retrieve text via JavaScript evaluation, enabling end-to-end web testing in Nightwatch.
Learn to use the Nightwatch recorder via the Chrome extension to record form interactions, export as a Nightwatch script, import into your project, and run tests.
Learn to create and use custom commands in Nightwatch to cleanly structure end-to-end web tests, including login and scroll helpers that export and reuse across tests.
Learn more in less time .This course is best suited for Beginners and Intermediate level guys who wanna learn web automation with ease .
In this course you will learn end to end about using Nightwatch js tool with both Javascript and Typescript . Main goal of this course is to achieve /learn more about automation testing in short time .After completing this course you will be able to design a framework from scratch with page Objects and beautiful test case reporting with logs and screenshots attached and many other things.I request everyone to please plug In your ear phones when watching this course so it will be much clear . Initially we will be learning Nightwatch Js configuration which is root for starting automation .you need to have a little javascript programming knowledge .In case if you're already working on test automation tools like selenium java => after taking up this course you will feel too easier as we write very less code and achieve more.
->Nightwatch Basics
Setting up environment
WebDriver manager (manage server and drivers automatically)
How to auto take screenshot on failure
How to use environments
How to use launch Url flag
How to not skip test cases on failure
Retries
Soft Assertions
Hard Assertions
using element method
running tests in headless mode
How to run single test case
How to run single test file
find Elements in Nightwatch
window handling
frames
moveToElement , scroll actions
Handling Alerts , PopUps
Debugging Nightwatch tests
cucumber
Page Object model using class style
Page Object model using functional style
And many more…
->Nightwatch reporting with mocha , Nightwatch html reporter and others
-> Page Objects
-> we will be covering Nightwatch with javascript & typescript
-> Nightwatch Cucumber
-> Nightwatch mocha and mochawesome
-> Nightwatch custom commands
-> GitHub actions
About Tool :
Nightwatch.js is one of the popular integrated framework for performing automated end-to-end testing on web applications and websites, across all major browsers. It is written in Node.js and uses the W3C WebDriver API to interact with various browsers.
It is a complete end-to-end and cross-browser testing solution and it aims to simplify the process of writing and running various types of tests.
Note: I suggest to use mocha runner so you can leverage mochawesome reporting which is very famous and neat