2

I am completely new to Selenium, and just want to install & run the example to begin with, as described here: http://www.seleniumhq.org/docs/03_webdriver.jsp I have installed the Java SE 9.0.1 JDK, Eclipse IDE for Java Developers and Apache Maven. Next I set up a pom.xml file:

<?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-server</artifactId>
                <version>3.0.1</version>
            </dependency>
        </dependencies>
</project>

Then I did mvn clean install

Then I imported the Maven project into Eclipse.

I also installed the m2eclipse plugin.

I called the project MySel20Proj.

Here, I created a class: Selenium2Example.java

Here, i pasted the code from the manual:

package org.openqa.selenium.example;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

public class Selenium2Example {
     public static void main(String[] args) {
        // Create a new instance of the Firefox driver
        // Notice that the remainder of the code relies on the interface, 
        // not the implementation.
        WebDriver driver = new FirefoxDriver();

        // And now use this to visit Google
        driver.get("http://www.google.com");
        // Alternatively the same thing can be done like this
        // driver.navigate().to("http://www.google.com");

        // Find the text input element by its name
        WebElement element = driver.findElement(By.name("q"));

        // Enter something to search for
        element.sendKeys("Cheese!");

        // Now submit the form. WebDriver will find the form for us from the element
        element.submit();

        // Check the title of the page
        System.out.println("Page title is: " + driver.getTitle());

        // Google's search is rendered dynamically with JavaScript.
        // Wait for the page to load, timeout after 10 seconds
        (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {
                return d.getTitle().toLowerCase().startsWith("cheese!");
            }
        });

        // Should see: "cheese! - Google Search"
        System.out.println("Page title is: " + driver.getTitle());

        //Close the browser
        driver.quit();
    }

}

The instructions seem to stop here. What do I do next? How do I run it?

Update 11/12/2017

I am now making some progress with this. The project is finally running, although it is not yet performing the test.

This is my latest POM file:

<?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">
     <properties>
        <maven.compiler.source>1.6</maven.compiler.source>
        <maven.compiler.target>1.6</maven.compiler.target>
      </properties>         
    <modelVersion>4.0.0</modelVersion>
    <groupId>MySel20Proj</groupId>
    <artifactId>MySel20Proj</artifactId>
    <version>1.0</version>
    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>3.8.1</version>
        </dependency>
    </dependencies>
     <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20.1</version>
            <configuration>
              <includes>
                <include>Selenium2Example.java</include>
              </includes>
            </configuration>
          </plugin>
        </plugins>
      </build>
</project>

This is the java code:

//package org.openqa.selenium.example;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

public class Selenium2Example {
 public static void main(String[] args) {
        // Create a new instance of the Firefox driver
        // Notice that the remainder of the code relies on the interface, 
        // not the implementation.
        System.out.println("Hello world!");
        System.setProperty("webdriver.gecko.driver", 
"C:\\Users\\sstaple\\Downloads\\geckodriver\\geckodriver.exe");

        WebDriver driver = new FirefoxDriver();

        // And now use this to visit Google
        driver.get("http://www.google.com");
        // Alternatively the same thing can be done like this
        // driver.navigate().to("http://www.google.com");

        // Find the text input element by its name
        WebElement element = driver.findElement(By.name("q"));

        // Enter something to search for
        element.sendKeys("Cheese!");

        // Now submit the form. WebDriver will find the form for us from the 
element
        element.submit();

        // Check the title of the page
        System.out.println("Page title is: " + driver.getTitle());

        // Google's search is rendered dynamically with JavaScript.
        // Wait for the page to load, timeout after 10 seconds
        (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>
() {
            public Boolean apply(WebDriver d) {
                return d.getTitle().toLowerCase().startsWith("cheese!");
            }
        });

        // Should see: "cheese! - Google Search"
        System.out.println("Page title is: " + driver.getTitle());

        //Close the browser
        driver.quit();
    }

}

This was the result of running mvn install in the Command Prompt:

> C:\Users\sstaple\eclipse-workspace\MySel20Proj>mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MySel20Proj 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MySel20Proj ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MySel20Proj ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MySel20Proj ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MySel20Proj ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Users\sstaple\eclipse-workspace\MySel20Proj\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ MySel20Proj ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running Selenium2Example
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 s - in Selenium2Example
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MySel20Proj ---
[INFO] Building jar: C:\Users\sstaple\eclipse-workspace\MySel20Proj\target\MySel20Proj-1.0.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ MySel20Proj ---
[INFO] Installing C:\Users\sstaple\eclipse-workspace\MySel20Proj\target\MySel20Proj-1.0.jar to C:\Users\sstaple\.m2\repository\MySel20Proj\MySel20Proj\1.0\MySel20Proj-1.0.jar
[INFO] Installing C:\Users\sstaple\eclipse-workspace\MySel20Proj\pom.xml to C:\Users\sstaple\.m2\repository\MySel20Proj\MySel20Proj\1.0\MySel20Proj-1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.089 s
[INFO] Finished at: 2017-12-11T11:31:42Z
[INFO] Final Memory: 16M/55M
[INFO] ------------------------------------------------------------------------

Update 2 - 11/12/2017

Had to add a bunch of Depencies to the pom file to get it to compile clean:

<dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>3.8.1</version>
    </dependency>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib-nodep</artifactId>
        <version>3.2.4</version>
    </dependency>
    <dependency>
        <groupId>com.codeborne</groupId>
        <artifactId>phantomjsdriver</artifactId>
        <version>1.3.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.3.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>21.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.netty/netty -->
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty</artifactId>
        <version>3.5.7.Final</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform -->
    <dependency>
        <groupId>net.java.dev.jna</groupId>
        <artifactId>jna-platform</artifactId>
        <version>4.1.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/net.sourceforge.cssparser/cssparser -->
    <dependency>
        <groupId>net.sourceforge.cssparser</groupId>
        <artifactId>cssparser</artifactId>
        <version>0.9.20</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/net.sourceforge.htmlunit/htmlunit-core-js -->
    <dependency>
        <groupId>net.sourceforge.htmlunit</groupId>
        <artifactId>htmlunit-core-js</artifactId>
        <version>2.23</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/net.sourceforge.htmlunit/htmlunit -->
    <dependency>
        <groupId>net.sourceforge.htmlunit</groupId>
        <artifactId>htmlunit</artifactId>
        <version>2.23</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/net.sourceforge.htmlunit/neko-htmlunit -->
    <dependency>
        <groupId>net.sourceforge.htmlunit</groupId>
        <artifactId>neko-htmlunit</artifactId>
        <version>2.23</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.4</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.4.4</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime -->
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpmime</artifactId>
        <version>4.5.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-io -->
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-io</artifactId>
        <version>9.2.15.v20160210</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-util -->
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-util</artifactId>
        <version>9.2.15.v20160210</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-api -->
    <dependency>
        <groupId>org.eclipse.jetty.websocket</groupId>
        <artifactId>websocket-api</artifactId>
        <version>9.2.15.v20160210</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-client -->
    <dependency>
        <groupId>org.eclipse.jetty.websocket</groupId>
        <artifactId>websocket-client</artifactId>
        <version>9.2.15.v20160210</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-common -->
    <dependency>
        <groupId>org.eclipse.jetty.websocket</groupId>
        <artifactId>websocket-common</artifactId>
        <version>9.2.15.v20160210</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/htmlunit-driver -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>htmlunit-driver</artifactId>
        <version>2.23</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/jetty-repacked -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>jetty-repacked</artifactId>
        <version>9.2.13.v20160825</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-api -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-api</artifactId>
        <version>3.8.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>3.0.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-edge-driver -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-edge-driver</artifactId>
        <version>3.0.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-firefox-driver -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>3.8.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-ie-driver -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-ie-driver</artifactId>
        <version>3.8.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.8.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-opera-driver -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-opera-driver</artifactId>
        <version>3.8.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-remote-driver -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-remote-driver</artifactId>
        <version>3.8.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-safari-driver -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-safari-driver</artifactId>
        <version>3.0.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-support -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-support</artifactId>
        <version>3.8.1</version>
    </dependency>

Still does nothing at all:

> C:\Users\sstaple\eclipse-workspace\MySel20Proj>mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MySel20Proj 1.0
[INFO] ------------------------------------------------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/com/google/guava/guava/21.0/guava-21.0.jar
Downloaded from central: https://repo.maven.apache.org/maven2/com/google/guava/guava/21.0/guava-21.0.jar (2.5 MB at 2.6 MB/s)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MySel20Proj ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ MySel20Proj ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MySel20Proj ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ MySel20Proj ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\sstaple\eclipse-workspace\MySel20Proj\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ MySel20Proj ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running Selenium2Example
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 s - in Selenium2Example
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MySel20Proj ---
[INFO] Building jar: C:\Users\sstaple\eclipse-workspace\MySel20Proj\target\MySel20Proj-1.0.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ MySel20Proj ---
[INFO] Installing C:\Users\sstaple\eclipse-workspace\MySel20Proj\target\MySel20Proj-1.0.jar to C:\Users\sstaple\.m2\repository\MySel20Proj\MySel20Proj\1.0\MySel20Proj-1.0.jar
[INFO] Installing C:\Users\sstaple\eclipse-workspace\MySel20Proj\pom.xml to C:\Users\sstaple\.m2\repository\MySel20Proj\MySel20Proj\1.0\MySel20Proj-1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.032 s
[INFO] Finished at: 2017-12-11T13:56:34Z
[INFO] Final Memory: 19M/63M
[INFO] ------------------------------------------------------------------------
Steve Staple
  • 2,983
  • 9
  • 38
  • 73

1 Answers1

2

As per the code block you have shared everything looks fine. But again as you mentioned org.seleniumhq.selenium selenium-server 3.0.1 you have to mandatory download geckodriver binary from this repository and place it in your system. Next in your code block you need to mention as follows :

System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();

Execution Steps :

  1. Save the Selenium2Example.java and the pom.xml file
  2. In the Package Explorer, right click on pom.xml, select Run As and select Maven clean
  3. In the Package Explorer, right click on pom.xml, select Run As and select Maven install.
  4. In the Package Explorer, right click on pom.xml, select Run As and select Maven test.

Update 1

As you are seeing the error as selection does not contain a main type, ensure that your .java file is within \ProjectSpace\src\test\java\.


Update 2

As you still see No sources to compile, as a last resort, Clean all of your Projects within your IDE, Close the IDE, Delete the ~\.m2 (MAVEN_HOME) sub-directory from the system forcefully. Take a System Reboot and execute your Test. Additionally from the command line even you can do a mvn clean, mvn install and mvn test.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thank you DebanjanB. I have done all that. Nothing at all happened. After Maven Test, the Console says: No sources to compile. I expected the example to actually work!?! – Steve Staple Dec 08 '17 at 16:37
  • 1
    As a last resort, `Clean` all of your `Projects` within your `IDE`, `Close` the `IDE`, `Delete` the `m2` (Maven_HOME) folder from the system forcibly. Take a `System Reboot`. try to `Execute` you `Test`. Additionally from the command line even you can do a **`mvn clean`**, **`mvn install`** and **`mvn test`** – undetected Selenium Dec 08 '17 at 16:41
  • OK. I have moved Selenium2Example.java to the folder eclipse-workspace\MySel20Proj\src\test\java, done mvn clean, mvn install and mvn test. Says build success, but nothing happened. I am thinking it should load a browser & go to Google! I do not see a Maven_HOME folder? – Steve Staple Dec 08 '17 at 16:59
  • 1
    Maven by default picks up class files with *Test* in the name, either change name or include the class in the pom. Details refer this - http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html. Plus maven will pick up test methods which are annotated with the Test annotation from junit or testng. It will not run main methods. https://www.testwithspring.com/lesson/running-unit-tests-with-maven/ – Grasshopper Dec 08 '17 at 17:58
  • Thank you Grasshopper. You would think whoever composed the Example on the SeleniumHQ website would have written an example that worked. A bit useless if Maven does not pick up Main methods, for example. The instructions leave a lot to be desired - and are incomplete. – Steve Staple Dec 11 '17 at 10:08
  • I am not sure how @Grasshopper concludes that. However I still continue to run some of my `Tests` from a `Maven Project` as a `Java Project` without involving the `TestNG`. Can we have some more insights please? – undetected Selenium Dec 11 '17 at 10:14
  • Getting this example to work is just one problem after another! Now getting this error: at org.apache.bcel.verifier.exc.AssertionViolatedException.main(AssertionViolatedException.java:102). the jar file M2_REPO\xalan\xalan\2.7.2\xalan-2.7.2.jar has no source attachment. – Steve Staple Dec 11 '17 at 10:40
  • Issue with `M2_REPO`, Clean all of your Projects within your IDE, Close the IDE, Delete the m2 (MAVEN_HOME) folder from the system forcibly. Take a System Reboot. Try to Execute you Test. Additionally from the command line even you can do a mvn clean, mvn install and mvn test. Btw how does the `xalan-2.7.2.jar` comes into picture? – undetected Selenium Dec 11 '17 at 10:41
  • Thanks DebanjanB. I cannot see any Maven_HOME folder. It is not shown as a Path Variable in the Projects Properties. I have no idea why it wanted the xalan-2.7.2.jar. but it appears to be a Maven resource. (https://mvnrepository.com/artifact/xalan/xalan/2.7.2). None of this information is included on the SeleniumHQ website. – Steve Staple Dec 11 '17 at 10:54
  • See on Windows machine `C:\Users\\.m2` is my **MAVEN_HOME** or **M2_REPO**. Delete this folder and take a fresh `maven clean & install`. Remove unwanted Maven Dependencies from your **`pom.xml`** as well. – undetected Selenium Dec 11 '17 at 10:58
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/160923/discussion-between-steve-staple-and-debanjanb). – Steve Staple Dec 11 '17 at 10:59
  • Use updated `Selenium v3.8.1` Maven Dependency. As per your code you don't need a `xalan-2.7.2.jar` – undetected Selenium Dec 11 '17 at 11:00
  • Guess maven also runs test methods with the string 'test' in them, though i have always worked with the annotation. Regarding running main method you will need to configure another plugin, exec-maven-plugin. Refer to this link - http://www.mojohaus.org/exec-maven-plugin/. @SteveStaple The documentation is a lot to be desired and also outdated with latest version, but it is open source and volunteer contributed. Better option would be to refer to millions of selenium tutorials. – Grasshopper Dec 11 '17 at 11:04
  • Thank you Grasshopper. Could you recommend a decent tutorial? It is pretty difficult trying to learn with this example. – Steve Staple Dec 11 '17 at 11:18
  • Thank you DebanjanB. I got further this time. I deleted the folder \.m2. Then I rebooted my laptop. Then I did mvn clean & mvn install. It actually produced this output: [INFO] Running Selenium2Example [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 s - in Selenium2Example. It is not what I was expecting, but progress is being made. – Steve Staple Dec 11 '17 at 11:24
  • Get the entire error stack trace within the question area please. – undetected Selenium Dec 11 '17 at 11:27
  • Thank you DebanjanB. I have updated the original question. – Steve Staple Dec 11 '17 at 11:43
  • Your `pom.xml` is clearly missing the **`maven-compiler-plugin`**. Once you add it you would be through. – undetected Selenium Dec 11 '17 at 11:54
  • Have had to add a load of depencies to the pom file to get a clean compile. The project now compiles, but still does nothing at all when I run it. – Steve Staple Dec 11 '17 at 14:05
  • I do not think it is running my code at all. I put System.out.println("Hello world!"); at the top of the procedure so that I would at least see something. Still nothing. – Steve Staple Dec 11 '17 at 14:07