I cant find how to set request headers within selenium chrome webdriver (python). I need to set "host" header. I tryed that:
from selenium import webdriver
from pyvirtualdisplay import Display
from selenium.webdriver import DesiredCapabilities
url = 'http://localhost:888/test'
display = Display(visible=0, size=(800, 800))
display.start()
desired_capabilities = DesiredCapabilities.CHROME.copy()
desired_capabilities['chrome.page.customHeaders.host'] = 'test.local'
driver = webdriver.Chrome('/tmp/chromedriver',
desired_capabilities=desired_capabilities)
driver.get(url)
And result:
GET /test HTTP/1.1
Host: localhost:888
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/53.0.2785.143 Chrome/53.0.2785.143 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
So, I expected header host:test.local
but found that Host: localhost:888
What I am doing wrong? I cant find how to set headers with Chrome webdriver :(
host
headers. How can I do that? – Prerecord