Go to the blog: http://www.cnblogs.com/puresoul/p/3483055.html
Operation encountered error: Webdriver Unable to connect to host 127.0.0.1 on port 7055 after 45000 MS Update Selenium-java.jar package to the latest;
* Development environment:
1.jdk1.7
2.eclipse,:http://www.eclipse.org/downloads/
3.selenium-java-2.44.0.jar,:http://docs.seleniumhq.org/download/
Unzip the Selenium-java as shown:
4.firefox 33.1
*eclipse:
1. Create a new Java project: Extract the Selenium-java files to the new project;
2. Add build path, project directory right-click-->build path--> Config build Path-->java build Path-->libraries-->add External JARs
Add all the jar packages under the Libs folder and add selenium-java-2.44.0 and Selenium-java-2.44.0-srcs
3. After adding the directory structure such as, more referenced Libraries, here is the above step added to the jar package
4. Associated Webdriver Source: Expand Referenced Libraries folder, select Selenium-java-2.44.0.jar, right click Properties-->java source attachment-- >external location Select the path where Selenium-java-2.44.0-srcs.jar is located (the path to the current project);
At this point the environment is configured to complete;
Example
1. New test class under SRC: New test Package com.selenium.demo--> new test class Testselenium.java
2. The code is as follows:
Package Com.selenium.Glen;
Import Org.openqa.selenium.By;
Import Org.openqa.selenium.WebDriver;
Import org.openqa.selenium.WebElement;
Import org.openqa.selenium.firefox.*;
public class Testhelloworld {
public static void Main (string[] args) {
If Firefox is not installed by default on the C drive, you need to set its path
System.setproperty ("Webdriver.firefox.bin", "D:/program Files/mozilla firefox/firefox.exe");
Webdriver Driver = new Firefoxdriver ();
Driver.get ("http://www.baidu.com/");
Driver.manage (). window (). Maximize ();
Webelement txtbox = driver.findelement (By.name ("WD"));
Txtbox.sendkeys ("Selenium");
Webelement btn = driver.findelement (by.id ("su"));
Btn.click ();
Driver.close ();
}
}
Then directly right-click-->run As-->java application can see the effect.
SELENIUM2 (webdirver) Getting Started Environment Building (Java Edition)