title: Python Selenium Headless Error: Element not Interactable
body: <p>I was making a program which scrapes info about stocks from the website <a href="https://www.tradingview.com/screener/" rel="nofollow noreferrer">https://www.tradingview.com/screener/</a> which used selenium.here is the code:</p>
  <pre class="lang-py prettyprint-override"><code>def stock(aaa):
      a=[]
      chrome_options = Options()
      custom_header = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'}
      chrome_options.add_argument(&quot;--headless&quot;)
      chrome_options.add_argument(f&quot;user-agent={custom_header}&quot;)
      chrome_options.add_argument(&quot;--disable-gpu&quot;)
     
      browser = webdriver.Chrome(options=chrome_options)
      browser.get(&quot;https://www.tradingview.com/screener/&quot;)
      entry=browser.find_element_by_css_selector(&quot;#js-screener-container &gt; div.tv-data-table-sticky-wrapper.tv-screener-sticky-header-wrapper &gt; table &gt; thead &gt; tr &gt; th.tv-data-table__th.tv-data-table__cell.js-tv-data-table-th.js-tv-data-table-th-name.tv-data-table__sortable.tv-screener-table__sortable.tv-screener-table__th.js-draggable &gt; div &gt; div &gt; div.tv-screener-table__search-query.js-search-query.tv-screener-table__search-query--without-description&gt;input&quot;)
      entry.send_keys(aaa)
  
  </code></pre>
  <p>It was working well when it was not in headless mode,but when I switched to headless,it gave this error code:</p>
  <pre><code>File &quot;c:\Users\██████\cowination.py&quot;, line 181, in &lt;module&gt;
      aaa=stock(&quot;zydus&quot;)
    File &quot;c:\Users\██████\cowination.py&quot;, line 20, in stock
      entry.send_keys(aaa)
    File &quot;C:\Users\████████████\Python39\lib\site-packages\selenium\webdriver\remote\webelement.py&quot;, line 477, in send_keys
      self._execute(Command.SEND_KEYS_TO_ELEMENT,
    File &quot;C:\Users\████████████\Python39\lib\site-packages\selenium\webdriver\remote\webelement.py&quot;, line 633, in _execute
      return self._parent.execute(command, params)
    File &quot;C:\Users\████████████\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py&quot;, line 321, in execute
      self.error_handler.check_response(response)
    File &quot;C:\Users\████████████\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py&quot;, line 242, in check_response
      raise exception_class(message, screen, stacktrace)
  selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
    (Session info: headless chrome=90.0.4430.212)
  </code></pre>
  <p>At first I thought it was because the window was not maximized as the entry box is not visible when not maximized.So I added the <code>--start-maximized</code> argument,but it too didn't work.I tried even Webdriverwait,but that to didn't work. So is there any way  I can solve this problem?
  thanks in advance</p>
  <p>Edit:
  I have written my code according to the correct answer.here is the code:
  from selenium import webdriver</p>
  <pre><code>from selenium.webdriver.chrome.options import Options
  import time
  from selenium.webdriver.common.keys import Keys
  from selenium.webdriver.common.action_chains import ActionChains
  def stock(aaa):
      a=[]
      chrome_options = Options()
      custom_header = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'}
      chrome_options.add_argument(&quot;--headless&quot;)
      chrome_options.add_argument(f&quot;user-agent={custom_header}&quot;)
      chrome_options.add_argument(&quot;--disable-gpu&quot;)
     
      browser = webdriver.Chrome(options=chrome_options)
      browser.get(&quot;https://www.tradingview.com/screener/&quot;)
      browser.maximize_window()
      time.sleep(3)
      e=browser.find_element_by_xpath(&quot;/html/body/div[6]/div/div[2]/div[8]/div[1]/img&quot;)
      e.click()
      from selenium.webdriver.common.action_chains import ActionChains
      ActionChains(browser).move_to_element(browser.find_element_by_css_selector('#js-screener-container &gt; div.tv-screener-toolbar.tv-screener-toolbar--standalone.tv-screener-toolbar--standalone_sticky &gt; div.tv-screener-market-select.tv-dropdown.tv-dropdown--inline.tv-dropdown-behavior.i-opened &gt; div.tv-dropdown__body.tv-dropdown-behavior__body.tv-dropdown__body--over-trigger.tv-dropdown__body--position_right.undefined.i-opened &gt; div &gt; div.tv-dropdown-behavior__inscroll.js-content &gt; div:nth-child(19) &gt; div &gt; span')).perform()
      india=browser.find_element_by_css_selector('#js-screener-container &gt; div.tv-screener-toolbar.tv-screener-toolbar--standalone.tv-screener-toolbar--standalone_sticky &gt; div.tv-screener-market-select.tv-dropdown.tv-dropdown--inline.tv-dropdown-behavior.i-opened &gt; div.tv-dropdown__body.tv-dropdown-behavior__body.tv-dropdown__body--over-trigger.tv-dropdown__body--position_right.undefined.i-opened &gt; div &gt; div.tv-dropdown-behavior__inscroll.js-content &gt; div:nth-child(19) &gt; div &gt; span')
      india.click()
      time.sleep(1)
      filters=browser.find_element_by_css_selector(&quot;#js-screener-container &gt; div.tv-screener-toolbar.tv-screener-toolbar--standalone.tv-screener-toolbar--standalone_sticky &gt; div.tv-screener-toolbar__button.tv-screener-toolbar__button--options.tv-screener-toolbar__button--filters.apply-common-tooltip.common-tooltip-fixed&quot;)
      filters.click()
      time.sleep(1)
      reset=browser.find_element_by_css_selector(&quot;#overlap-manager-root &gt; div &gt; div &gt; div &gt; div.tv-screener-search.js-screener-search &gt; div&quot;)
      reset.click()
      exitbut=browser.find_element_by_css_selector(&quot;#overlap-manager-root &gt; div &gt; div &gt; div &gt; div.tv-dialog__section.tv-dialog__section--title.tv-tabbed-dialog__header.js-close-button-place &gt; div.tv-dialog__close.js-dialog__close.tv-tabbed-dialog__close&quot;)
      exitbut.click()
      time.sleep(3)
      entry=browser.find_element_by_css_selector(&quot;#js-screener-container &gt; div.tv-data-table-sticky-wrapper.tv-screener-sticky-header-wrapper &gt; table &gt; thead &gt; tr &gt; th.tv-data-table__th.tv-data-table__cell.js-tv-data-table-th.js-tv-data-table-th-name.tv-data-table__sortable.tv-screener-table__sortable.tv-screener-table__th.js-draggable &gt; div &gt; div &gt; div.tv-screener-table__search-query.js-search-query.tv-screener-table__search-query--without-description&gt;input&quot;)
      
      browser.execute_script(&quot;$('.tv-screener-table__search-input.js-search-input').val('{}');&quot;.format(aaa))
      action = webdriver.ActionChains(browser);
      action.send_keys(Keys.RETURN).send_keys(Keys.BACKSPACE).perform()
      time.sleep(6)
      p=browser.find_element_by_css_selector(&quot;#js-screener-container &gt; div.tv-screener__content-pane &gt; table &gt; tbody &gt; tr:nth-child(1) &gt; td.tv-data-table__cell.apply-common-tooltip.tv-screener-table__cell.tv-screener-table__cell--left.tv-screener-table__cell--with-marker &gt; div &gt; div:nth-child(3) &gt; span.tv-screener__description&quot;)
      p1=browser.find_element_by_css_selector(&quot;#js-screener-container &gt; div.tv-screener__content-pane &gt; table &gt; tbody &gt; tr:nth-child(1) &gt; td:nth-child(2) &gt; span&quot;)
      a.append(p.text)
      a.append(p1.text)
      p2=browser.find_element_by_css_selector(&quot;#js-screener-container &gt; div.tv-screener__content-pane &gt; table &gt; tbody &gt; tr:nth-child(1) &gt; td:nth-child(3)&quot;)
      p3=browser.find_element_by_css_selector(&quot;#js-screener-container &gt; div.tv-screener__content-pane &gt; table &gt; tbody &gt; tr:nth-child(1) &gt; td:nth-child(4)&quot;)
      a.append(p2.text)
      a.append(p3.text)
      p4=browser.find_element_by_css_selector(&quot;#js-screener-container &gt; div.tv-screener__content-pane &gt; table &gt; tbody &gt; tr:nth-child(1) &gt; td:nth-child(5) &gt; span&quot;)
      a.append(p4.text)
      p5=browser.find_element_by_css_selector(&quot;#js-screener-container &gt; div.tv-screener__content-pane &gt; table &gt; tbody &gt; tr:nth-child(1) &gt; td:nth-child(6)&quot;)
      a.append(p5.text)
      p6=browser.find_element_by_css_selector(&quot;#js-screener-container &gt; div.tv-screener__content-pane &gt; table &gt; tbody &gt; tr:nth-child(1) &gt; td:nth-child(7)&quot;)
      a.append(p6.text)
      p7=browser.find_element_by_css_selector(&quot;#js-screener-container &gt; div.tv-screener__content-pane &gt; table &gt; tbody &gt; tr:nth-child(1) &gt; td:nth-child(8)&quot;)
      a.append(p7.text)
      p8=browser.find_element_by_css_selector(&quot;#js-screener-container &gt; div.tv-screener__content-pane &gt; table &gt; tbody &gt; tr:nth-child(1) &gt; td:nth-child(9)&quot;)
      a.append(p8.text)
  
      p10=browser.find_element_by_css_selector(&quot;#js-screener-container &gt; div.tv-screener__content-pane &gt; table &gt; tbody &gt; tr:nth-child(1) &gt; td:nth-child(11)&quot;)
      a.append(p10.text)
      return f&quot;&quot;&quot;Name of stock:{a[0]}
      Last price:{a[1]}
      Change %:{a[2]}
      Change value:{a[3]}
      Rating:{a[4]}
      Volume:{a[5]}
      Market Cap:{a[6]}
      Price to Earning Ratio:{a[7]}
      EPS(TTM):{a[8]}
      Sector:{a[9]}
      &quot;&quot;&quot;
  </code></pre>
  <p>here is the output :</p>
  <pre><code>Name of stock:RELIANCE INDUSTRIES LTD.
      Last price:2000.90
      Change %:0.79%
      Change value:15.60
      Rating:Buy
      Volume:210.603K
      Market Cap:12.656T
      Price to Earning Ratio:—
      EPS(TTM):—
      Sector:Energy Minerals
  </code></pre>
  <p>this is the expected output:</p>
  <pre><code>Name of stock:ZYDUS WELLNESS LTD.
          Last price:2110.15
          Change %:-0.57%
          Change value:-12.15
          Rating:Buy
          Volume:24.03K
          Market Cap:134.251B
          Price to Earning Ratio:114.58
          EPS(TTM):18.52
          Sector:Consumer Non-Durables
  </code></pre>
  <p>Now it is typing in the search box but giving wrong output which is actually the info of the stock at the homepage and not that of the search results .
  Can anyone tell why it is happening?</p>