My simple selenium python script to test how proxy fails. How to force webdriver work through proxy connection?
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
PROXY_HOST = "{MYIP}"
PROXY_PORT = 11200
PROXY_USERNAME = "{UNAME}"
PROXY_PASSWORD = "{PW}"
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=http://%s:%s@%s:%s' % (PROXY_USERNAME, PROXY_PASSWORD, PROXY_HOST, PROXY_PORT))
chrome_options.add_argument("ignore-certificate-errors")
chrome = webdriver.Chrome(options=chrome_options)
chrome.get("https://www.ipchicken.com/")
# Wait until a table is present
wait = WebDriverWait(chrome, 30) # Adjust the timeout as needed
wait.until(EC.presence_of_element_located((By.TAG_NAME, "table")))
# Get the page source
page_source = chrome.page_source
# Output page data as text in console
print(page_source)
# Close the browser
chrome.quit()
It works good if i remove Proxy settings, but, it throws TimeoutException with proxy settings.
My proxy credentials are correct and work well through CURL.