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?
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?
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()