title: How to enable JavaScript with headless Chrome in selenium
body: <pre><code>import requests
  from bs4 import BeautifulSoup
  from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC
  from selenium.webdriver.chrome.options import Options
  import time
  
  def checkLinkedIn(command):
      url = f&quot;https://www.linkedin.com/in/{command}&quot;
      path = &quot;C:\Program Files (x86)\chromedriver.exe&quot;
      options = Options()
      options.add_argument(&quot;--headless&quot;)
      driver = webdriver.Chrome(path, options=options)
      driver.get(url)
      soup = BeautifulSoup(driver.page_source, 'html.parser')
      time.sleep(2)
      driver.quit()
      name = soup.find(&quot;h1&quot;, attrs={&quot;class&quot;: &quot;top-card-layout__title&quot;})
      if name:
          print(&quot;LinkedIn profile found&quot;)
          print(url)
      else:
          print(&quot;No LinkedIn profile found&quot;)
  
  def checkTwitter(command):
      url = f&quot;https://www.twitter.com/{command}&quot;
      path = &quot;C:\Program Files (x86)\chromedriver.exe&quot;
      options = Options()
      options.add_argument(&quot;--headless&quot;)
      driver = webdriver.Chrome(path, options=options)
      driver.get(url)
      soup = BeautifulSoup(driver.page_source, 'html.parser')
      time.sleep(2)
      driver.quit()
      at_tag = soup.find(&quot;div&quot;, attrs={&quot;dir&quot;: &quot;ltr&quot;})
      print(soup.text)
      if at_tag:
          print(&quot;Twitter profile found&quot;)
          print(url)
      else:
          print(&quot;No Twitter profile found&quot;)
  
  usrname = input(&quot;--&gt; &quot;)
  
  checkTwitter(usrname)
  </code></pre>
  <p>The LinkedIn function works. However, the Twitter one comes up with this:</p>
  <p><em><strong>JavaScript is not available.
  We’ve detected that JavaScript is disabled in this browser. Please enable JavaScript or switch to a supported browser to continue using twitter.com. You can see a list of supported browsers in our Help Centre.</strong></em></p>
  <p>How do I enable Javascript in a headless Chrome? Thanks in advance.</p>