0

我正在我正在测试的同一系统上运行项目文件我正在使用 selenium web 驱动程序和 eclipse 来测试项目,但是当我运行 selenium 脚本来测试登录页面时显示错误。

**error** :

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
    l,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},
"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1462864767739,"updateDate":1462864767739,"applyBackgroundUpdates":1,"skinnable":true,"size":22012,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"
{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"46.0.1","maxVersion":"46.0.1"}],"targetPlatforms":[],"seen":true}

so after this i had set the proxy 
and tried but the result was same 
but when i tried to copy the link and manually pasted it in Mozilla and searched it was successfully showing the login page

代码硒

包装测试

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

public class demo {

    `public static void main(String[] args) {
        WebDriver driver= new Firefox Driver();
        driver.get("localhost:8080/Chaitanya");
        driver.findElement(By.name("username")).send Keys("login");
        driver.findElement(By.name("login.password")).send Keys("password");
     `   
4

2 回答 2

0

很少有拼写错误....

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

public class demo {

    public static void main(String[] args) {
        WebDriver driver= new FirefoxDriver();
        driver.get("http://localhost:8080/Chaitanya");
        driver.findElement(By.name("username")).sendKeys("login");
        driver.findElement(By.name("login.password")).sendKeys("password");
}

如果仍然发生同样的错误。请将 Selenium Jar 更新到最新版本(http://www.seleniumhq.org/download/),并将 Firefox 浏览器更新到最新版本。

于 2016-05-18T09:58:11.830 回答
0

我最近的项目中遇到了同样的问题(仅供参考:问题是由端口引起的),对此的修复是:

尝试更新最新版本的硒,这应该可以解决它。如果没有,解决这个问题的肮脏工作是

    WebDriver driver;     
    try {
    driver = new FirefoxDriver();
    }
    catch(Exception e) {
    driver = new FirefoxDriver();
    }
于 2016-05-18T10:07:12.077 回答