SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.7k stars 8.19k forks source link

Unable to execute WebDriver scripts using Ant, Maven and testng #2305

Closed gitissuepost closed 8 years ago

gitissuepost commented 8 years ago

Meta -

OS: Windows 7

Selenium Version: 2.53

Browser: Firefox

Browser Version: 2.46

Expected Behavior -

Ant build.xml will run my webdriver script

Actual Behavior -

It is ending up with an exception below. com.google.common.collect.Multimaps.transformValues(Lcom/google/common/collect/ListMultimap;Lcom/google/common/base/Function;)Lcom/google/common/collect/ListMultimap; at com.google.common.net.MediaType.toString(MediaType.java:668) at org.openqa.selenium.remote.http.JsonHttpCommandCodec.encode(JsonHttpCommandCodec.java:232) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:139) at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:160) at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:380) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:216) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:211) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:207) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120) at testng.advanced.practice.TestNGAnnotations.superTest(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86) at org.testng.internal.Invoker.invokeMethod(Invoker.java:643) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) at org.testng.TestRunner.privateRun(TestRunner.java:782) at org.testng.TestRunner.run(TestRunner.java:632) at org.testng.SuiteRunner.runTest(SuiteRunner.java:366) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319) at org.testng.SuiteRunner.run(SuiteRunner.java:268) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244) at org.testng.TestNG.runSuitesLocally(TestNG.java:1169) at org.testng.TestNG.run(TestNG.java:1064) at org.testng.TestNG.privateMain(TestNG.java:1385) at org.testng.TestNG.main(TestNG.java:1354)

Steps to reproduce -

Build.xml <?xml version="1.0" encoding="UTF-8"?>

``` ```

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">

4.0.0
<groupId>TestNG_Advanced</groupId>
<artifactId>TestNG_Advanced</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
    <log4j.version>1.2.17</log4j.version>
    <selenium.version>2.53.0</selenium.version>
    <testng.version>6.9.10</testng.version>
</properties>

<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>testng.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>${testng.version}</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>${selenium.version}</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>${log4j.version}</version>
    </dependency>
</dependencies>

testng.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

TestAnnonations.java package testng.advanced.practice;

import java.io.IOException; import java.util.Date;

import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.Reporter; import org.testng.annotations.Test;

public class TestNGAnnotations { @Test(dependsOnMethods = { "superTest", "dependTest" }) public void testNGTest() { Reporter.log("In Test"); }

@Test
public void dependTest() throws IOException {
    Reporter.log("Depend Test");
}

@Test
public void superTest() {
    Reporter.log("Super Test");
    WebDriver driver = new FirefoxDriver();
    driver.get("http://www.google.com");
}

}

gitissuepost commented 8 years ago

Not sure why I am unable to see the testng.xml. Here it is `

`

lukeis commented 8 years ago

We only troubleshoot selenium issues here, not ant. You can try to ask for help on the selenium-users google group.

Since you mentioned Firefox, I'm going to assume you're using the latest (47) and if so this is a duplicate issue of #2110