0

Maven や Selenium を使用したことがないので、非常に簡単な質問があります。このチュートリアルに従っています: http://docs.seleniumhq.org/docs/03_webdriver.jsp

そのため、mvn clean install を実行し、プロジェクトを NetBeans にインポートした後 (projet/open project メニューを使用)。ウィザード (新規 => Java メイン クラス) を使用して新しいメイン クラスを作成し、プロジェクトをビルドしました。

ビルドは成功しましたが、プロジェクトを実行しようとすると、「メイン クラスが見つかりません」と表示されます。

なぜ?

私のプロジェクト フォルダーは /user/webtest2/ で、メイン クラス ファイル (Selenium2Example.java) はこのプロジェクトのルート フォルダーにあります (pom.xml として)。

4

2 に答える 2

0

Ok, I have looked at the pom.xml in my maven webdriver project and I think you should chcek this:

 <!-- Create JAR manifest with main class, but without Maven descriptor, so clients don't see this file -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <addMavenDescriptor>false</addMavenDescriptor>
                    <manifest>
                        <mainClass>com.deutscheboerse.test.MyTest</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>

While in the projet folder I have under package com.deutscheboerse.test created file (java Class) which is named MyTest and this class contains main method. Snippet from the code:

public static void main(String[] args) throws Exception {
    myTest(args[0], args[1], args[2], price);

}

While the method mytest() does the magic:

public static void myTest(String driver, String login, String password, Price price) throws Exception {
    PerfTests tests = new PerfTests(USED_ENVIRONMENT, driver);

    tests.login(login, password);
    //... and other steps
}

Long story short Check that your pom.xml contains path to the main class and this class actually contains main method

于 2013-05-23T08:39:51.723 に答える