简体   繁体   English

尝试使用Selenium WebDriver测试Web应用程序时,弹出一个错误,提示无法连接到本地主机

[英]Trying to test a web application using selenium webdriver, a error that pops showing not abe to connect to the local host

i am running the project file on the same system on which i am testing i am using selenium web driver and eclipse for testing the project but error is shown, when i run the selenium script for testing login page. 我在要测试的同一系统上运行项目文件,我正在使用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

CODE SELENIUM 代码硒

Package TESTING 包测试

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");
     `   

There few typo error.... 几乎没有拼写错误。

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");
}

if Still same error occurs. 如果仍然发生相同的错误。 Please update Selenium Jar to latest( http://www.seleniumhq.org/download/ ), and update Firefox browser to latest version. 请将Selenium Jar更新到最新版本( http://www.seleniumhq.org/download/ ),并将Firefox浏览器更新到最新版本。

I had same issue in my recent project (FYI: issue is caused by port) , fixes for this is: 我在最近的项目中遇到了同样的问题(仅供参考:问题是由端口引起的),此问题的解决方法是:

Try to update latest version of selenium, this should fix it. 尝试更新硒的最新版本,这应该可以解决。 if not, dirty work around for this is 如果没有,这是肮脏的工作

    WebDriver driver;     
    try {
    driver = new FirefoxDriver();
    }
    catch(Exception e) {
    driver = new FirefoxDriver();
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Selenium Webdriver 连接远程数据库并通过 Eclipse 从本地机器运行测试用例 - Connect Remote Database using Selenium Webdriver and run Test Cases from local machine through eclipse 使用 Selenium WebDriver 的 Spring Boot Web 应用程序 - Spring Boot Web Application using Selenium WebDriver 我们如何使用Java中的Selenium Webdriver测试不同语言(非英语)的Web应用程序 - How can we test a web application in different language(not english) using selenium webdriver in Java 不能在 VM 上执行我的 selenium 测试 - Not abe to execute my selenium test on VM 如何使用Selenium WebDriver在UI下测试RESTful Web服务 - How to test RESTful web services under UI using selenium webdriver 在 Java 程序 (Firefox) 中使用 Selenium Webdriver 获取无法连接错误 - Getting cannot connect error using Selenium Webdriver in Java program (Firefox) 使用Selenium WebDriver运行测试 - Run a test using selenium webdriver 在本地主机上运行Web应用程序 - Running web application on local host 当我在Chrome中运行此Selenium Webdriver测试时,将弹出空白页 - Blank page pops up when i run this selenium webdriver test in chrome 在Selenium Webdriver中找不到Web应用程序的元素 - Not able to find element of a web application in selenium webdriver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM