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”);


7 thoughts on “Selenium RC Error – SeleniumException: XHR ERROR

    • Pavandeep Puddupakkam says:

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

        • 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();
          }
          }

  1. 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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>