Selenium
is automation tool for testing web applications.
We will create test with Javascript, Firefox, Node.js. This test will open Firefox browser and search for string Selenium
.
Installation
//Install Node.js and Npm
//Install Gecko Driver for Firefox
wget https : //github.com/mozilla/geckodriver/releases/download/v0.29.0/geckodriver-v0.29.0-linux64.tar.gz
tar - xvzf geckodriver *
chmod + x geckodriver
sudo mv geckodriver / usr / local / bin /
Create new folder and inside that index.js
.
npm init
npm install selenium - webdriver @ 3 . 6.0 //latest version didnt work for me
index.js
const { Builder , By , Key , util } = require ( ' selenium-webdriver ' );
async function example () {
let driver = await new Builder (). forBrowser ( " firefox " ). build ();
await driver . get ( " http://google.com " );
await driver . findElement ( By . name ( " q " )). sendKeys ( " Selenium " , Key . RETURN );
}
example ();
Run it with:
node index . js