简体   繁体   中英

Setting Up a Selenium-WebDriver Project

I would like to automate Firefox using Java (and eclipse) through a Selenium-WebDriver project.

I am also following the directions at http://www.seleniumhq.org/docs/03_webdriver.jsp#setting-up-webdriver-project .

I have created a Selenium folder in c:/Java/Selenium.

However, nothing happen (not Maven installation) when I try to the following :

from a command-line, CD into the project directory and run maven as follows.

mvn clean install

Below is the content of my pom.xml (I am not sure about what version to be equally updated).

Thanks in advance for your help.

<?xml version="1.0" encoding="UTF-8"?>
<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>MySel20Proj</groupId>
        <artifactId>MySel20Proj</artifactId>
        <version>1.0</version>
        <dependencies>
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-java</artifactId>
                <version>2.42.2</version>
            </dependency>
            <dependency>
                <groupId>com.opera</groupId>
                <artifactId>operadriver</artifactId>
            </dependency>
        </dependencies>
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>com.opera</groupId>
                    <artifactId>operadriver</artifactId>
                    <version>1.5</version>
                    <exclusions>
                        <exclusion>
                            <groupId>org.seleniumhq.selenium</groupId>
                            <artifactId>selenium-remote-driver</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
        </dependencyManagement>
</project>

I know its not your specially asked. But I think this is the easiest way to set up the selenium project.

http://www.softwaretestingclub.com/profiles/blogs/selenium-2-0-webdriver-how-to-configure-selenium-webdriver-in

It will open you a firefox and you can do everything you want. You only need the selenium libaries and firefox path:

public void setUp() throws Exception {
    System.setProperty("webdriver.firefox.bin","C:\\Users\\your_user\\AppData\\Local\\Mozilla Firefox\\Firefox.exe");
    driver = new FirefoxDriver();

}

its not in the example but its need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM