I was trying to use addCustomRequestHeader method to set a custom header for selenium requests. Given below is the source code
Selenium sel = new DefaultSelenium("localhost",4444,"*firefox","http://www.google.com");
sel.start("addCustomRequestHeader=true");
// sel.start();
sel.addCustomRequestHeader("mycustomheader","automation");
sel.open("http://www.google.com/");
This code didn't add the header to the request. I tried to look up the request headers using Fiddler. Does any one here know what am I doing wrong here? Any help would be appreciated
You need to start the selenium in proxy injection mode
java -jar selenium-server-standalone.jar -proxyInjectionMode
You can then add custom requests headers like this (in Python)
sel.start("addCustomRequestHeader=true")
sel.add_custom_request_header("mycustomheader","automation")
sel.open('http://www.google.com')
To see if the custom header has been applied, check the tab that has the selenium server running. You should see something like this in the console messages
INFO - Command request: addCustomRequestHeader[mycustomheader, automation] on session
INFO - Got result: OK on session
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With