I\'m trying to add headers into my HTTP
request for a particular test case. That\'s very important since I\'m trying to test an application meant to be used in
I started out in a different place than you, but then ended up with the same result as you; "How do I add a request header to selenium". I know it's been a while since you posted your original question, so this is for anyone that is looking for the answer in Java. Here is some code I came up with to add request headers to your selenium request in JAVA:
public class MyTestCase extends SeleneseTestCase {
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost");
selenium.start("addCustomRequestHeaders=true");
selenium.open("/");
}
@Test
public void testMyTestCase() {
selenium.addCustomRequestHeader("HEADER_NAME", "HEADER_VALUE");
//header "HEADER_NAME", with "HEADER_VALUE" is now in your request
selenium.click("link=Hello World");
}
}
Update You will also have to start your selenium server with the ' -addCustomRequestHeader' input variable. For example:
%java_home%\bin\java -jar selenium-server-standalone-2.25.0.jar -addCustomRequestHeader