title: Selenium webdriver not working in Electron build
body: <p>I have an electron project that renders an html page with a button that when clicked calls a node js script (via IPC) which uses selenium to scrape webpages.</p>
  
  <p>here’s my project structure:</p>
  
  <pre><code>
      -app/
       --index.html
       --main.js
       --index.js
      -package.json
  
  </code></pre>
  
  <p>Here’s my package.json:</p>
  
  <pre><code>    {
          "name": "agencies-scraper",
          "version": "1.0.0",
          "main": "app/main.js",
          "devDependencies": {
              "electron": "^5.0.7",
              "electron-builder": "^21.1.1"
          },
          "scripts": {
              "start": "electron .",
              "pack": "electron-builder --dir",
              "dist": "electron-builder",
              "postinstall": "electron-builder install-app-deps"
          },
          "build": {
              "appId": "my.id",
              "files": [
                  "app/**/*",
                  "node_modules/**/*",
                  "package.json"
              ],
              "mac": {
                  "category": "your.app.category.type"
              },
          },
          "dependencies": {
              "csv-writer": "^1.5.0",
              "selenium-webdriver": "^4.0.0-alpha.4"
          }
      }
  
  </code></pre>
  
  <p>In index.html I have a button:</p>
  
  <pre><code>
      &lt;button id="test"&gt;Click to Scrape&lt;/button&gt;
  
  </code></pre>
  
  <p>When clicked it fires the following chain of reactions:</p>
  
  <ol>
  <li>The linked index.js, send a signal to the “backchannel” ipc channel:</li>
  </ol>
  
  <pre><code>
      const {ipcRenderer} = require("electron");
      const button = document.getElementById("test");
      button.addEventListener("click", () =&gt; {
        ipcRenderer.send("backchannel"); 
      }
  
  </code></pre>
  
  <ol start="2">
  <li>In main.js, I listen to “backchannel”, and when triggered, instantiate a selenium webdriver and open google.com in a separate chrome browser:</li>
  </ol>
  
  <pre><code>const {app, BrowserWindow, ipcMain} = require('electron')
  const webdriver = require('selenium-webdriver')
  
  ipcMain.on('backchannel', async (event, arg) =&gt; {
      const driver = new webdriver.Builder()
              .forBrowser('chrome')
              .build()
      try {
          await driver.get('https://google.com');
      } catch (error) {
          console.log(error)
      }
  })
  </code></pre>
  
  <ol start="3">
  <li>The os asks if I want the electron app to accept incoming connections and I click “Allow” (selenium opens a browser regardless):
  <img src="https://sjc1.discourse-cdn.com/business6/uploads/github_atom/original/3X/2/2/22e2470cbce75d1531b7416fdc60c92aeaa07ce4.png" alt="Permission popup screenshot"></li>
  </ol>
  
  <p>This works perfectly when I work in development via <code>npm start</code>.</p>
  
  <p>However, when I package the app either via <code>npm run-script pack</code> or <code>npm run-script dist</code>, the build version does not reach step 3. No permission window pops up and no browser opens. Selenium just doesn’t work there.</p>
  
  <p>I am sure the IPC is working from index.js to main.js in the build version so the issue is not with that. What am I missing here?</p>