
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 .
This lecture updated on Nov23 2022
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
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']
}
}
Hi Guys , in this video , we will group our tests and run them
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
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