为什么URL不能在FirefoxDriver中使用Selenium?

时间:2018-01-11 16:33:57

标签: selenium selenium-webdriver testng selenium-chromedriver selenium-firefoxdriver

我有Selenium,TestNG和maven应用程序。

如果我运行mvn intergration-test,则会打开Firefox浏览器,但网址无效。

在控制台中也出现以下错误

Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7055

我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.selenium</groupId>
<artifactId>Selenium</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Selenium</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <version.selenium>2.53.1</version.selenium>
    <version.testng>6.9.10</version.testng>
    <version.maven.compiler.plugin>2.3.2</version.maven.compiler.plugin>
    <version.java.source>1.8</version.java.source>
    <version.java.target>1.8</version.java.target>
</properties>

<dependencies>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>${version.testng}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <!-- <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-server-standalone</artifactId> 
            <version>${version.selenium}</version> <scope>test</scope>  -->
         <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.53.1</version> 
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${version.maven.compiler.plugin}</version>
            <configuration>
                <source>${version.java.source}</source>
                <target>${version.java.target}</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <argLine>-Xms128m -Xmx256m -XX:PermSize=128m -XX:MaxPermSize=256m</argLine>
                <parallel>true</parallel>
                <suiteXmlFiles>
                    <suiteXmlFile>src/main/java/com/selenium/testng.xml</suiteXmlFile>
                </suiteXmlFiles>
                <!-- Skip the normal tests, we'll run them in the integration-test phase -->
                <skip>true</skip>
            </configuration>
            <executions>
                <execution>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <skip>false</skip>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

1 个答案:

答案 0 :(得分:1)

当浏览器版本与您的驱动程序版本不兼容时,我通常会看到这样的行为,从您看到您使用的是selenium v​​er 2.25,这有点旧,我认为只支持FF 14.请确认您是使用正确版本的Firefox。如果你需要帮助安装旧版本的Firefox,请看:

https://support.mozilla.org/en-US/kb/install-older-version-of-firefox