title: Trying to validate the complete loading of a page in selenium python through a VM
body: <p>I am trying to run a simple selenium automation script (which just loads up google ,searches for youtube and hits the search button) through a virtual machine.So when i set up the options/parameters as shown in the code below (even setting headless mode on), this is what i have:
  #Beginning of code</p>
  <pre><code>from pyvirtualdisplay import Display   
  from selenium import webdriver  
  from selenium.webdriver.firefox.firefox_binary import FirefoxBinary  
  from selenium.webdriver.common.desired_capabilities import DesiredCapabilities.  
  from selenium.webdriver.firefox.options import Options 
  from selenium.webdriver.support.ui import WebDriverWait  
  from selenium.webdriver.common.keys import Keys
  
  display =Display(visible=0, size=(1024,768))  
  display.start()  
  options = Options()  
  options.headless = False  
  caps = DesiredCapabilities.FIREFOX  
  caps['marionette'] = False  
  binary = FirefoxBinary('/home/a-user/Al/firefox/firefox')  
  browser = webdriver.Firefox(firefox_binary= binary, options = options, capabilities= caps,executable_path=r&quot;/home/a-user/Al/firefox/geckodriver&quot;)  
  browser.get('https://www.google.com')  
  browser.find_element_by_name('q').send_keys(&quot;Youtube&quot;)
  browser.find_element_by_xpath('//[@id=&quot;tsf&quot;]/div[2]/div[1]/div[3]/center/input[1]').send_keys(Keys.ENTER)  
  print(&quot;Headless Firefox Initialized&quot;)  
  browser.close()  
  display.stop()
  </code></pre>
  <p>#End of code</p>
  <p>But when i try to run it, it shows:<br />
  ---Beginning of error message ----</p>
  <pre><code>Traceback (most recent call last):   
   File &quot;test.py&quot;, line 17, in &lt;module&gt;
     browser.find_element_by_name('q').send_keys(&quot;Youtube&quot;)  
   
  File &quot;/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py&quot;, line 496, in find_element_by_name
     return self.find_element(by=By.NAME, value=name)    
   File &quot;/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py&quot;, line 978, in find_element
     'value': value})['value']    
   File &quot;/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py&quot;, line 321, in execute
     self.error_handler.check_response(response)   
   File &quot;/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py&quot;, line 242, in check_response
     raise exception_class(message, screen, stacktrace)    
  selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {&quot;method&quot;:&quot;name&quot;,&quot;selector&quot;:&quot;q&quot;}
  Stacktrace:      
  at FirefoxDriver.prototype.findElementInternal_(file:///tmp/tmpG1qHlX/extensions/fxdriver@googlecode.com/components/driver-component.js:11885)  
  at FirefoxDriver.prototype.findElement (file:///tmp/tmpG1qHlX/extensions/fxdriver@googlecode.com/components/driver-component.js:11894)      
  at DelayedCommand.prototype.executeInternal_/k(file:///tmp/tmpG1qHlX/extensions/fxdriver@googlecode.com/components/command-processor.js:13395)   
  at DelayedCommand.prototype.executeInternal_ (file:///tmp/tmpG1qHlX/extensions/fxdriver@googlecode.com/components/command-processor.js:13400)    
  at DelayedCommand.prototype.execute/&lt; (file:///tmp/tmpG1qHlX/extensions/fxdriver@googlecode.com/components/command-processor.js:13342)
  </code></pre>
  <p>I was wondering if theres any way I can make sure the page gets loaded properly, then continue with the automated interaction with the elements.Thanks in advance for the help!</p>