Selenium+Java+Firefox+Windows无法正常工作
我需要以下组合的帮助, 操作系统:Windows 10 使用的浏览器:Firefox 45.0.1 Java版本:Java 8更新51 64位 硒:图书馆2.47.1 我们的代码很简单Selenium+Java+Firefox+Windows无法正常工作,java,selenium,firefox,Java,Selenium,Firefox,我需要以下组合的帮助, 操作系统:Windows 10 使用的浏览器:Firefox 45.0.1 Java版本:Java 8更新51 64位 硒:图书馆2.47.1 我们的代码很简单 import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; import org.testng.annotations.Test; import org.testng.annotations.BeforeM
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.testng.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
//import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class TestClass01
{
static final Logger logger1 = LogManager.getLogger(TestClass01.class.getName());
WebDriver driver ;
String baseUrl ;
static int testCount = 0 ;
String[] content_heading ;
List<WebElement> temp_list ;
WebDriverWait wait;
boolean exists;
@BeforeClass
public void beforeClass()
{
logger1.entry();
logger1.info("Entering the class : " + this.getClass().getSimpleName() );
driver = new FirefoxDriver();
baseUrl = "http://www.google.com";
logger1.info("Maximizing the browser window and setting up the implicit timeout for element/page loading....");
driver.manage().window().maximize();
//Specifies the amount of time the driver should wait when searching for an element
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
logger1.info("Fetching the Homepage for Jacuzzi");
// launch Firefox and direct it to the Base URL
driver.get(baseUrl+"/");
}
}
但是,它抛出以下错误:
org.openqa.selenium.firefox.NotConnectedException:无法连接
45000毫秒后,在端口7055上承载127.0.0.1。Firefox控制台输出:
调试更新的XPIState
{id:{972ce4c6-7e08-4474-a285-3208198ce6fd},syncGUID:BbZlO30v46U7,位置:应用程序全局,版本:45.0.1,类型:主题,内部名称:classic/1.0,updateURL:null,updateKey:null,选项URL:null,选项类型:null,关于URL:null,图标:{32:icon.png,48:icon.png},iconURL:null,icon64URL:null,默认语言环境:{name:Default,描述:The
违约
主题,创建者:Mozilla,主页URL:null,贡献者:[Mozilla]
贡献者]},可见:真,活动:真,用户禁用:假,应用禁用:假,描述符:C:\Program
文件x86\Mozilla
Firefox\browser\extensions\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi,安装日期:1458533973089,更新日期:1458533973089,applyBackgroundUpdates:1,skinnable:true,size:22012,sourceURI:null,releaseNotesURI:null,softDisabled:false,foreignInstall:false,HasryComponents:false,StricCompatibility:true,locales:[],TargetApplication:[{id:{ec8030f7-c20a-464f-9b0e-13a3a9e97384},最小版本:45.0.1,最大版本:45.0.1}],目标平台:[],见:真]
这是因为firefox最新浏览器出现了新问题 更新selenium JAR。Firefox或其他浏览器的新版本不支持旧的selenium JAR 下载Selenium服务器和Selenium RC服务器Selenium客户端和WebDriver语言绑定 用您正在使用的旧JAR替换它们。同时更新您的mozilla,以便获得更新的结果 资料来源: 为了解决这个问题,您还需要将preference设置为xpinstall.signatures.required,将其设置为false,并将其传递给firefox配置文件,然后将其传递给驱动程序对象
firefoxProfile.setPreference("xpinstall.signatures.required", false);
下面的代码对我来说很好
static WebDriver driver=null;
public static void main(String[] args) {
final FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("xpinstall.signatures.required", false);
driver = new FirefoxDriver(firefoxProfile);
driver.get("https://www.google.de/");
希望它能对你有所帮助:大部分是在线提供的-确实非常有用。请尝试降级。非常感谢。在遵循你的建议后,它工作正常。