0

The thing what I wanted to do was automate the Firefox browser for search an item in the search bar. My java codes are as follows.

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class FlipkartTest {

    public static void main(String[] args) {

        CharSequence[] cs = {"Dell"};
        //CharSequence[] d = String[]{"Dell"};
        //String s = toString();        

        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.flipkart.com");
        driver.findElement(By.id("fk-top-search-box")).sendKeys(cs);
        driver.findElement(By.xpath("//input[@value=Search]")).click();
    }
}

After debug or run the code a new Firefox window is appeared, But when click on next Annotation button, Nothing was happened. it doesn't go for next step such as opens the Flipcart.com site or searches the word.

After run the code, The console display a list. I found this line from it.

Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.

So how I fix this problem?

  • can u tell us what are u trying exactly so that we would understand it better – Mrunal Gosar Jan 05 '16 at 14:48
  • I wanted to Automate the browser with selenium web driver. I write that codes by looking at a tutorial. first it opens the Firefox, then go to flipkart.com. type a string in the search bar and submit. But after run the code, it opens the firefox browser only. – Tharindu Kandegedara Jan 06 '16 at 03:18
  • well the code here does the same thing and it works well for me https://github.com/mrunalgosar/cucumber-demo/blob/master/src/main/java/flipkart/FlipkartImpl.java – Mrunal Gosar Jan 06 '16 at 05:37
  • In my peace of codes, nothing error is showing. but it does not continue next steps. Can be any other reason for that. – Tharindu Kandegedara Jan 06 '16 at 07:28
  • try to run your code in debug mode and see which line is problematic – Mrunal Gosar Jan 06 '16 at 08:24
  • 1
    Take a look at [this](http://stackoverflow.com/questions/12588082/webdriver-unable-to-connect-to-host-127-0-0-1-on-port-7055-after-45000-ms) – Guy Jan 06 '16 at 08:37
  • @guy , I got the point from your link. It is 3 rd answer of it. The problem is about selenium standalone server version. I have added the version 2.44 of selenium. Then I added latest version 2.48 which compatible with Firefox 43.0.3. If you can give it as an answer, I can accept it. – Tharindu Kandegedara Jan 06 '16 at 09:35

2 Answers2

1

As been answered here the problem is in mismatch between selenium and Firefox. Updating them to the latest version should solve the problem.

Community
  • 1
  • 1
Guy
  • 46,488
  • 10
  • 44
  • 88
  • I got the point from your link. It is 3 rd answer of it. The problem is about selenium standalone server version. I have added the version 2.44 of selenium. Then I added latest version 2.48 which compatible with Firefox 43.0.3. If you can edit this answer, I can accept it. – Tharindu Kandegedara Jan 06 '16 at 09:46
1

I recommend you to first set the properties of the Firefox driver and then create an instance of it. Something like this -

Webdriver driver=null;
System.setProperty("webdriver.firefox.driver"."//your firefox driver path");
driver=new FirefoxDriver();

Also try with ChromeDriver and InternetExplorerDriver and check if the problem still persists.

Aritro Sen
  • 357
  • 7
  • 14