I have a very basic Python script that runs perfectly on my local machine (Mint 19), and yet fails on a remote box (Ubuntu 16.04). Same files, both Python 3.7. I have geckod
This information log...
INFO - Application - Start test1.py:12: DeprecationWarning: use setter for headless property instead of set_headless opts.set_headless(headless=True)
...implies that the set_headless opts.set_headless(headless=True)
is deprecated and you have to use the setter for headless property as follows:
opts = Options()
opts.headless = True
driver = webdriver.Firefox(options=opts)
driver.get("https://www.krypterro.com")
You can find the detailed discussion in How to make firefox headless programmatically in Selenium with python?
Moving ahead as you are trying to retrive the Page Source and as the Web Application is JavaScript enabled you need to induce WebDriverWait and you can use the following solution:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
driver.get("https://www.krypterro.com")
WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//h2[contains(.,'Products and Services')]")))
html_src = driver.page_source
print(html_src)
driver.quit()
Note B: You don't need to invoke driver.close()
and driver.quit()
rather always invoke driver.quit()
only within tearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.