I encountered an issue while trying to import a JavaScript file into my server-side JavaScript file. The function I need to run cannot be executed on the server side. Is there a method to successfully import my source code to the server-side JavaScript file so that the function can be executed? Your assistance is greatly appreciated.
JavaScript file for exporting 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")
}
})();