0
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://google.com")
driver.implicitly_wait(80)
print driver.page_source.encode('utf-8')

Where is the catch and why it is not opening?

1 Answers1

0

You should use the implicit_wait before the driver.get

from selenium import webdriver
driver = webdriver.Firefox()
driver.implicitly_wait(10) # seconds
driver.get("http://somedomain/url_that_delays_loading")
myDynamicElement = driver.find_element_by_id("myDynamicElement")

An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.

Regarding your question in comments:

import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options


executable_path = "path_to_webdriver"
os.environ["webdriver.chrome.driver"] = executable_path

chrome_options = Options()
chrome_options.add_extension('path_to_extension')

driver = webdriver.Chrome(executable_path=executable_path, chrome_options=chrome_options)
driver.get("http://stackoverflow.com")
driver.quit()
omri_saadon
  • 10,193
  • 7
  • 33
  • 58
  • no in chrome no extension are loading up so i need t stick to firefox –  Jan 31 '17 at 08:34
  • @Rakeshmoorthy I was confused as one of your tags is google-chrome, edited my answer – omri_saadon Jan 31 '17 at 08:35
  • got error os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. Exception AttributeError: "'Service' object has no attribute 'process'" in > ignored –  Jan 31 '17 at 08:36
  • @Rakeshmoorthy You can read about your error in this [link](http://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path) – omri_saadon Jan 31 '17 at 08:39
  • omri_saadon do u know how to load extension with chrome when using selenium(im on ubuntu)? –  Jan 31 '17 at 08:39
  • @Rakeshmoorthy this is pretty long, so i've added this to my answer – omri_saadon Jan 31 '17 at 08:41
  • if i give my path here chrome_options.add_extension('path_to_extension') it is not working –  Jan 31 '17 at 08:42
  • may be i will use wrong path do u know how to find path –  Jan 31 '17 at 08:42
  • I use this path for now .config/google-chrome/Default/Extensions/nofbmmlgcejohbjpbilfpiggemkakkig –  Jan 31 '17 at 08:43