Selenium RC Error – SeleniumException: XHR ERROR 

When running the selenium script of a website I got the following error
com.thoughtworks.selenium.SeleniumException: XHR ERROR: URL = http://www.website.com.au/ Response_Code = 400 Error_Message = Bad Request.
The solution was pretty simple. Instead of using the url http://www.website.com.au/ change it to http://website.com.au/. Remove the www.
The reason is because there is no 301 re-direct is not setup for the website.
Originally the setup was – setUp(“http://www.website.com.au/”, “*chrome”);
Changed it to – setUp(“http://website.com.au/”, “*chrome”);


Author: Pavandeep Puddupakkam on February 15, 2011
Category: Automation Tips, Selenium RC
Tags: , , ,
Selenium Webdriver Forum -The Online Community for Selenium Webdriver and Selenium RC Users and Professionals
7 responses to “Selenium RC Error – SeleniumException: XHR ERROR”
  1. JAcek says:

    Hi what about if this solution not work and problem ocuurs with deleted www ?

    • Pavandeep Puddupakkam says:

      Can you confirm if you are able to get to the site/webpage manually? It may be getting redirected. 301 redirects.

      • JAcek says:

        Ye it is I confirming that
        plz contact by mail this is urgent issue

        • Pavandeep Puddupakkam says:

          Here is the test script I have written in Java – Selenium RC and I dont get any error:

          import com.thoughtworks.selenium.*;
          import org.junit.After;
          import org.junit.Before;
          import org.junit.Test;
          public class xtrade extends SeleneseTestCase {
          @Before
          public void setUp() throws Exception {
          selenium = new DefaultSelenium(“localhost”, 4444, “*chrome”, “http://www.xtb.pl”);
          selenium.start();
          }
          @Test
          public void testhomePage() throws Exception {
          selenium.open(“/”);
          try
          {
          assertEquals(“X-Trade Brokers”, selenium.getTitle());
          System.out.println(“The page title is correct”);
          }
          catch (Exception e)
          {
          System.out.println(“The page title is wrong”);
          }
          }
          @After
          public void tearDown() throws Exception {
          selenium.stop();
          }
          }

  2. JAcek says:

    Yes, I’m, site which i test as all xtb and I must set up accounts and when i play my test in local area this error appears

  3. Raj says:

    Hi Experts,
    i am new to Selenium.
    Whle i am trying to execute below junit code i am receiving below error .
    Could youplease let me know what could be the problem?

    Code:
    ——package com.example.tests;

    import org.junit.After;
    import org.junit.AfterClass;
    import org.junit.Before;
    import org.junit.BeforeClass;
    import org.junit.Test;
    //import org.openqa.selenium.server.RemoteControlConfiguration;
    import org.openqa.selenium.server.SeleniumServer;

    import com.thoughtworks.selenium.*;

    public class ABCCls {
    private static SeleniumServer seleniumServer;
    private static Selenium selenium = new DefaultSelenium( “localhost”,4444, “*chrome”,”https://mzaz-qa.fundquest.com/”);

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {

    }

    @AfterClass
    public static void tearDownAfterClass() throws Exception {

    }

    @Test
    public void testUntitled() throws Exception {
    selenium.open(“/jazz/userSecurity/login.htm”);
    selenium.type(“username”, “redi2admin”);
    selenium.type(“password”, “redi2blue”);
    selenium.click(“saveAction”);
    selenium.waitForPageToLoad(“30000″);
    selenium.click(“//div[@id='subNavigationArea']/a[3]/span”);
    selenium.waitForPageToLoad(“30000″);
    selenium.type(“number”, “C54190258″);
    selenium.click(“searchAction__accounts”);
    selenium.waitForPageToLoad(“30000″);
    }

    @Before
    public void setUp() throws Exception {
    seleniumServer = new SeleniumServer();
    seleniumServer.start();
    selenium.start();
    }

    @After
    public void tearDown() throws Exception {
    selenium.stop();
    seleniumServer.stop();
    }

    Error
    ———-
    1:24:12.953 INFO – Preparing Firefox profile…
    11:24:16.546 INFO – Launching Firefox…
    11:24:21.718 INFO – Got result: OK,b5727bdb78fb4df4b7c98465cd102557 on session b5727bdb78fb4df4b7c98465cd102557
    11:24:21.734 INFO – Command request: open[/jazz/userSecurity/login.htm, ] on session b5727bdb78fb4df4b7c98465cd102557
    11:24:22.171 INFO – Got result: XHR ERROR: URL = https://jazz-qa.fundquest.com/jazz/userSecurity/login.htm Response_Code = -1 Error_Message = Request Error on session b5727bdb78fb4df4b7c98465cd102557

  4. Pavandeep Puddupakkam says:

    First think i would like to know is what is the test url; is it https://jazz-qa.fundquest.com or https://mzaz-qa.fundquest.com
    in DefaultSelenium give https://mzaz-qa.fundquest.com instead of https://mzaz-qa.fundquest.com/.

Leave a Reply

Last articles