我编写代码来测试注册表单,我收到浏览器的这个错误。
错误: -
org.openqa.selenium.firefox.NotConnectedException: Unable to
connect to host 127.0.0.1 on port 7055 after 45000 ms.
gcr.java类:
package SeleniumWebdriver;
//import java.util.Date;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class gcr {
public static void main(String args[]) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.gcrit.com/build3/");
driver.findElement(By.linkText("create an account")).click();
driver.findElement(By.xpath(".//*[@id='bodyContent']/form/div/div[2]/table/tbody/tr[1]/td[2]/input[1]")).click();
driver.findElement(By.name("firstname")).sendKeys("piyush");
driver.findElement(By.name("lastname")).sendKeys("kansal");
driver.findElement(By.name("dob")).sendKeys("10/01/1993");
/*Date date=new Date();
int x=date. getSeconds();*/
//String Email= "piyush@gmail.com";
driver.findElement(By.name("email_address")).sendKeys("piyush@gmail.com");
driver.findElement(By.name("street_address")).sendKeys("innotical");
driver.findElement(By.name("postcode")).sendKeys("251001");
driver.findElement(By.name("city")).sendKeys("noida");
driver.findElement(By.name("state")).sendKeys("Up");
Select Dropdown = new Select(driver.findElement(By.name("country")));
Dropdown.selectByVisibleText("India");
driver.findElement(By.name("telephone")).sendKeys("9958097200");
driver.findElement(By.name("password")).sendKeys("9958097200");
driver.findElement(By.name("confirmation")).sendKeys("9958097200");
driver.findElement(By.id("tdb4")).click();
String Message = driver.findElement(By.xpath(".//*[@id='bodyContent']/h1")).getText();
if (Message.equals("Your Account Has Been Created!")) {
System.out.println("Account has created-passed");
} else {
System.out.println("Account not created-failed");
}
//driver.close();
}
}