I have developed a basic selenium application and now I am looking to implement a graphical user interface for it.
Here is the code snippet:
index.html:
<html>
<head>
<meta charset="UTF-8" />
<title>Selenium App</title>
<link rel="stylesheet" href="index.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9cfee9f0f1fddcacb2a5b2a8">[email protected]</a>/css/bulma.min.css">
<script defer src="selenium.js"></script>
</head>
<body>
<div class="align">
<h1>Selenium App</h1>
<button id="start" class="button is-primary">Start</button>
</div>
</body>
</html>
selenium.js:
startButton.onclick = initiateSelenium;
const {Builder, Browser, By, Key, until} = require('selenium-webdriver');
async function initiateSelenium() {
let driver = await new Builder().forBrowser("chrome").build();
await driver.get('https://google.com');
await driver.findElement(By.id("L2AGLb")).click()
await driver.findElement(By.xpath("/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input")).sendKeys("selenium",Key.RETURN);
}
I keep encountering an error message:
Uncaught ReferenceError: require is not defined
Any suggestions on how to solve this issue?