I was trying to import a JavaScript file to my server side JavaScript file because I can't run the function on my server side. Is there any way to import my src to server side js so that I can run the function. Thanks in advance.
JS file to export to server side
const {Builder, By, Key, util} = require("selenium-webdriver");
(async function googlesearch() {
let driver = await new Builder().forBrowser('chrome').build();
try{
await driver.get("https://www.google.com/");
let searchField = await driver.findElement(By.name('q'));
await searchField.sendKeys("workout videos");
await searchField.sendKeys(Key.ENTER);
await driver.wait(until.titleIs('workout videos - Google Search'), 5000);
let list = await driver.findElements(By.className('g'));
if(list.length <= 0 ){
throw new Error('Test - FAIL');
}else{
console.log('Test - Success');
}
} finally {
console.log("automation complete")
}
})();