2

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?

jww
  • 97,681
  • 90
  • 411
  • 885
Panacea
  • 247
  • 3
  • 7
  • 14
  • I've checked what was going on a tool called Proxomitron (http://www.proxomitron.info/) and I've discovered that Selenium client was sending 2 user-agent headers: one with Firefox value and other with the user-agent I was setting. So there is a bug in Selenium 1.0.3. What I did was to use Proxomitron to remove the wrong Firefox header. I'll try to write a post explaining all this in detail. For now, any people using Selenium RC just be aware of this bug. – Panacea Apr 07 '11 at 11:42

1 Answers1

1

Selenium RC : Setting up a Firefox proxy

This was to document setting up proxy arguments inside Firefox with Selenium RC but it describes how to use the Firefox Profile Manager.

Using this, you can invoke Firefox with whatever settings and add-ons you want

rbrayb
  • 46,440
  • 34
  • 114
  • 174