DeprecationWarning: use setter for headless property instead of set_headless opts.set_headless(headless=True) using Geckodriver and Selenium in Python DeprecationWarning: use setter for headless property instead of set_headless opts.set_headless(headless=True) using Geckodriver and Selenium in Python selenium selenium

DeprecationWarning: use setter for headless property instead of set_headless opts.set_headless(headless=True) using Geckodriver and Selenium in Python


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 = Truedriver = 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 WebDriverWaitfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support import expected_conditions as ECdriver.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.