1. Installation
NPM Install Selenium-webdriver--save
2. Create a file
Then build a folder e2e, in the folder inside create a Index.js
The contents are as follows
Const {Builder, by, Key, until}= Require (' Selenium-webdriver ');//the parameters needed to deconstruct the assignment(AsyncfunctionExample () {Let driver= awaitNewBuilder (). Forbrowser (' Firefox '). build (); Try{await driver.get (' https://www.baidu.com/');//Open that URL .Await Driver.findelement (by.name (' wd ')). SendKeys (' Selenium-webdriver ', Key.return);//Label Name= ' WD ' press ENTER to await Driver.wait (Until.titleis (' Selenium-webdriver_ Baidu Search '), 1000);//If the page title isselenium-webdriver_ baidu search 1s success
}finally{await driver.quit ();//do any tests must be done to quit } })();
3. Implementation
node./e2e/index.js
Selenium-webdriver Automated Testing tools