title: How to run javascript selenium function using a html button?
body: <p>This code works fine but I need to run this script on a html button means when the button is clicked then this function get executed!!!</p>
  
  <pre><code>async function example() {
      let driver = await new Builder().forBrowser("chrome").build();
      await driver.get("https://google.com");  
  }
  example();
  </code></pre>
  
  <p>I tried this but not working,</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
      &lt;title&gt;Javascript Testing&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;script type="text/Javascript"&gt;
          async function example()
          {
          const {Builder, By, Key, util} = require("selenium-webdriver")
          let driver = new Builder().forBrowser("chrome").build();
          driver.get("https://google.com");
          driver.findElement(By.name("q")).sendKeys("Selenium",KEY.RETURN);
          }
      &lt;/script&gt;
      &lt;button onClick="example()"&gt;Click me&lt;/button&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Error: </p>
  
  <pre><code>index.html Uncaught ReferenceError: example is not defined
      at HTMLButtonElement.onclick
  </code></pre>
  
  <p>and, I also tried it with external js but it still not working </p>