The main idea of using the Custom Headers in Selenium RC was to add the User-agent and the phone nomber to my HTTP requests. For that purpose, I'm using Selenium Server as a proxy in Firefox (see how-to use addCustomRequestHeader properly)
This is more or less the code I'm using:
@Before
public void setUp() throws Exception {
setUp(URL, NAVIGATOR);
selenium.start("addCustomRequestHeader=true");
Thread.sleep(5000);
selenium.windowMaximize();
}
@Test
public void testVerifyHomePage() {
System.out.println("**** testVerifyHomePage Executing");
selenium.addCustomRequestHeader("x-Nokia-Msisdn", "525554003650");
selenium.addCustomRequestHeader("User-Agent","Mozilla/5.0 (iPhone;");
selenium.open(URL);
selenium.waitForPageToLoad("30000");
verifyTextPresentErrorMsg(selenium,"Home Page");
System.out.println("---- testVerifyHomePage Finished");
}
The x-Nokia-Msisdn is sent correctly but the User-Agent is wrong (it always considers that my User-Agent is Moxilla Firefox and not a mobile phone). I've tried accessing to pages such as YouTube and the mobile version isn't displayed so this means that the User-Agent that I'm sending is not taken into account.
I've search on the internet and I found people with the same issue but no possible solution. What some people suggest is using a particular profile in Firefox + Modify Headers but I don't think this is possible since everytime Selenium starts an instance of Firefox it creates a plain version without addons.
Any suggestions?