title: Selenium not working in headless mode
body: <p>So I have a basic Selenium program, where you make it click on a button and you should get a "Hello World" text copied to your clipboard. The code works if it's not in headless mode, but I want it to work in headless mode. Here's the code with headless mode enabled:</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.chrome.options import Options
  import pyperclip
  
  CHROME_PATH = 'C:\\Program Files 
  (x86)\\Google\\Chrome\\Application\\chrome.exe'
  CHROMEDRIVER_PATH = 'C:\\Users\\ACER\\Desktop\\chromedriver_win32\\chromedriver.exe'
  chrome_options = Options()
  chrome_options.set_headless()
  driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH,
                            chrome_options=chrome_options
                           )  
  
  driver.get("file://C:/Users/ACER/Desktop/index.html")
  driver.find_element_by_class_name("button").click()
  
  message = pyperclip.paste()
  
  driver.close()
  
  if message == "":
      print("Failed")
  else:
      print(message)
  </code></pre>
  
  <p>Here is the HTML code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;style&gt;
    .wrapper {
     text-align: center;
  }
  
    .button {
     background-color: black;
     border: none;
     color: white;
     padding: 20px 30px;
     font-size:30px;
     cursor: pointer;
  }
  
    .button:hover {
     background-color: grey;
  }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div class="wrapper"&gt;
      &lt;button class="button" onclick="copyToClipboard('Hello World')"&gt;Click 
  Here&lt;/button&gt;
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
    function copyToClipboard(text){
         var dummy = document.createElement("input");
         document.body.appendChild(dummy);
         dummy.setAttribute('value', text);
         dummy.select();
         document.execCommand("copy");
         document.body.removeChild(dummy);
  }
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>