0

I've set up Eclipse with Maven and created a project adding Selenium and TestNG dependencies. I'm now trying to run my tests in Chrome and I know that I can set System.setProperty("webdriver.chrome.driver","C:\\path-to\\chromedriver.exe");, but I've also seen somewhere that the path to chromedriver can be established in the run configurations, thus avoiding to add configuration lines to the code.

I tried setting up a run configuration like this: eclipse run configuration

And this is the code in my test:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;

public class Demo {

    @Test
    public void demoTest(){
    WebDriver driver=new ChromeDriver();
    driver.manage().window().maximize();
    driver.get("http://www.google.com");
    driver.quit();

    }
}

But after running project as "Maven test" I get this and nothing happens (Chrome is not opened):

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building project-name 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ project-name ---
[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) @ project-name ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ project-name ---
[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) @ project-name ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ project-name ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.737 s
[INFO] Finished at: 2017-07-01T08:36:03-03:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------

What am I missing?

Floella
  • 1,279
  • 1
  • 22
  • 41
  • Can you point me to any documentation where you have `seen somewhere that the path to chromedriver can be established in the run configurations`? Thanks – undetected Selenium Jul 01 '17 at 11:53
  • Actually, it wasn't documentation but a friend that once showed me this kind of setup running in one of his projects. I can't ask him anymore, so I have to figure it out on my own. – Floella Jul 01 '17 at 12:23
  • 1
    Are you able to run with testng plugin? – Murthi Jul 01 '17 at 15:14
  • Possible duplicate of [Running JUnit tests with Maven under Eclipse](https://stackoverflow.com/questions/5451808/running-junit-tests-with-maven-under-eclipse) – K.Nicholas Jul 01 '17 at 17:00
  • @Anarelle So with `System.setProperty` it runs the test? or same behaviour? – Madhan Jul 02 '17 at 02:23
  • Actually, I used `System.setProperty` to set chromedriver path and I get the same behavior... so it doesn't seem to be picking up my test at all. – Floella Jul 02 '17 at 20:50
  • Actually, if I run as testNG, everything runs smoothly (my property set in the runner options seems to be working). Not sure why running as Maven doesn't work. – Floella Jul 02 '17 at 21:00
  • You created a run configuration but seems like you're not using it. Try to click in **Run > Run Configurations** menu, then select the run configuration you created, and click at "Run" button. – José Renato Jul 03 '17 at 00:01

1 Answers1

1

Can you try to run as a JUNIT and run in DEBUG mode so you will find the exact error i think first of all the test class is not picked,

run in DEBUG mode JUNIT and debug the code.. Hoping this will help you.