selenium 2.0 webdriver 测试编译错误

发布于 2024-11-15 14:43:04 字数 2336 浏览 1 评论 0原文

无论我使用哪个 Selenium 2.xx 版本的网络驱动程序,我都会遇到相同的编译错误

:读取 C:\Documents 时出错并且 设置\kondojis.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\2.0b3\selenium-firefox-driver-2.0b3.jar; 打开 zip 文件时出错

这是我的 POM 文件中的内容

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium</artifactId>
    <version>2.0rc2</version>
    <type>pom</type>  <i tried with and without type pom>
</dependency>

我正在使用 jdk 1.6、Maven 3.0.1 M 在 Windows XP 上使用 Maven 编译器插件 2.3.2 等

package com.usps.mgo.icoa.UI;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.apache.log4j.Logger;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;

import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import java.util.List;
import java.util.Locale;

/**
 * Created by IntelliJ IDEA.
 * User: kondojis
 * Date: 2/8/11
 * Time: 5:02 PM
 * To change this template use File | Settings | File Templates.
 */
public class SimulatorTests {
    private static final Logger logger = Logger.getLogger(SimulatorTests.class);
    private static WebDriver driver;
    private ReloadableResourceBundleMessageSource messageSource;
    private static ClassPathXmlApplicationContext springCtx;

    /**
     * Properties for Simulator tests
     */

    @Before
    public void setUp() {
        // Bootstrap Spring Framework.
        springCtx = new ClassPathXmlApplicationContext(
                new String[]{"test-config.xml"});
        //Make Sure that test_global.properties file is always in sync with the global.properties file from production.
        messageSource = springCtx.getBean("messageSource", ReloadableResourceBundleMessageSource.class);
        driver = new FirefoxDriver();
    }

No matter which Selenium 2.xx version web-drivers I use, I get the same compilation errors

: error reading C:\Documents and
Settings\kondojis.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\2.0b3\selenium-firefox-driver-2.0b3.jar;
error in opening zip file

This is what I have in my POM file

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium</artifactId>
    <version>2.0rc2</version>
    <type>pom</type>  <i tried with and without type pom>
</dependency>

I am using jdk 1.6, Maven 3.0.1 M am using Maven compiler plugin 2.3.2 etc on Windows XP

package com.usps.mgo.icoa.UI;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.apache.log4j.Logger;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;

import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import java.util.List;
import java.util.Locale;

/**
 * Created by IntelliJ IDEA.
 * User: kondojis
 * Date: 2/8/11
 * Time: 5:02 PM
 * To change this template use File | Settings | File Templates.
 */
public class SimulatorTests {
    private static final Logger logger = Logger.getLogger(SimulatorTests.class);
    private static WebDriver driver;
    private ReloadableResourceBundleMessageSource messageSource;
    private static ClassPathXmlApplicationContext springCtx;

    /**
     * Properties for Simulator tests
     */

    @Before
    public void setUp() {
        // Bootstrap Spring Framework.
        springCtx = new ClassPathXmlApplicationContext(
                new String[]{"test-config.xml"});
        //Make Sure that test_global.properties file is always in sync with the global.properties file from production.
        messageSource = springCtx.getBean("messageSource", ReloadableResourceBundleMessageSource.class);
        driver = new FirefoxDriver();
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浊酒尽余欢 2024-11-22 14:43:04

打开 zip 文件时出错听起来像是本地存储库中损坏的 jar。尝试删除“C:\Documents and Settings\kondojis.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\”目录并让maven重新下载它。

编辑:注意到您的硒依赖项和错误输出有不同的版本,我声明了一个手动依赖项,例如

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>2.0rc2</version>
        <scope>test</scope>
    </dependency>

Error in opening zip file sounds like a corrupted jar in your local repo. Try deleting the "C:\Documents and Settings\kondojis.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\" directory and making maven re-download it.

edit: Noticed your selenium dependency and error output have different versions, I declare a manual dependency like

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>2.0rc2</version>
        <scope>test</scope>
    </dependency>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文