I am using I wrote a small selenium script in javascript that executes find with node (filename.js) in the terminal but when I try to execute that script with a button click it doesnt work.
I took the guts out and put an alert() and it executed.
Just wondering if anyone can spot what I am doing wrong here?
Here is the script
async function example() {
const {Builder, By, Key, util} = require("selenium-webdriver");
require("chromedriver");
let driver = await new Builder().forBrowser("chrome").build();
await driver.get("http://google.com");
await driver.findElement(By.name("q")).sendKeys("Selenium Test", Key.RETURN);
}
And here is the php file I want to execute it from
<!doctype html>
<html lang="en">
<head>
<title>Sidebar 01</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script src="index.js"></script>
</head>
<body>
<center>
<button onclick="example();">Hello</button>
</center>
</body>
</html>