Selenium NPM Tutorial
First Test In Selenium JavaScript
How To Write A Selenium Test In JavaScript ?
Prerequisites :
Install Selenium JavaScript setup on an editor => Follow Guide
Writing a Selenium Test in JavaScript :
Open VS code,go to the File, click on Open folder.
Now browse to that project folder where setup has done for selenium javascript(In my case it's SeleniumJS.) and open it in editor.
Create a new folder as 'tests' in the project folder.
Create a '.js' file named 'FirstTest.js' in the folder tests.
The FirstTest.js file will be as :
* Create an asynchronous function.
async function firstTest
* Import selenium-webdriver and chromedriver.
let webdriver =require("selenium-webdriver");
require("chromedriver");
* Launch the web browser(chrome).
let driver=new webdriver.Builder().forBrowser("chrome").build();
* Navigate to the url 'https://www.myautomationhub.com/'.
* Quit the browser.
await driver.get("https://www.myautomationhub.com/");
await driver.quit();
* Call the function.
firstTest();
To run,navigate to the folder tests and then use command "node filename.js", i.e. "node FirstTest.js".