0

I have some tests using JUnit and Selenium, and I need to run it on the Chrome browser. I downloaded the Chrome driver, and configure my SetUp() as:

@Before
public void SetUp() throws Exception{
    System.setProperty("webdriver.chrome.driver","");
    driver = new ChromeDriver();
    baseUrl = ;
    driver.get(baseUrl);    
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);//Wait 5 seconds to load the page
}

The ChromeDriver.exe are added in my "Referenced Libraries" folder.
When I'll run the tests, the following error is displayed: java.lang.exception: No runnable methods

Anybody know how can I fix this?

SOLUTION

1º Add the chromedriver in the path of your computer. 2º Update your setProperty as: System.setProperty("webdriver.chrome.driver","C:\\Users\\pedro_nazario\\Desktop\\ChromeDriver\\chromedriver.exe"); The second parameter must be the way where is your Chromedriver.exe in my case, the chromedriver are in a folder on desktop.

The most important thing, that you never forget When you'll run the tests, before, close your Chrome browser completely. Any chrome browser must be open before you run your tests. If have some chrome browser opened, the selenium will take a error in your screen.

Pedro Henrique
  • 609
  • 2
  • 9
  • 26

1 Answers1

0

According to the documentation, webdriver.chrome.driver should contain the path to the chromedriver executable:

System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");

Alternatively, you can add path to the chromedriver to the PATH environment variable.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • @PedroHenrique are you sure the path to `chromedriver` is correct? Also, could you show the complete error traceback? Thanks. – alecxe Oct 31 '14 at 15:46
  • @PedroHenrique it could also be unrelated to chromedriver, see http://stackoverflow.com/questions/672466/junit-how-to-avoid-no-runnable-methods-in-test-utils-classes. – alecxe Oct 31 '14 at 15:48
  • My ChromeDriver are added in my Referenced Libraries. The Error traceback is here: http://pastebin.com/2aDZUQSZ – Pedro Henrique Oct 31 '14 at 15:49
  • @PedroHenrique yeah, it's not about chromedriver. Please show the complete code you have now. Thank you. – alecxe Oct 31 '14 at 15:50
  • I have the same class, but using firefox driver, and it's working fine, but, in Chrome, isn't work. – Pedro Henrique Oct 31 '14 at 15:52
  • @PedroHenrique please include the traceback and the complete code you have into the question - I'll delete the answer since it doesn't help. Thank you. – alecxe Oct 31 '14 at 16:26
  • Yeah looking at your code on pastebin, you've copy-pasted `System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");` directly. What Alecxe was saying was to include that property but set the second arguement to your actual path - not to `/path/to/chromedriver` but something like `c:\user\myreferencelibrary\chromedriver.exe` – Mark Rowlands Oct 31 '14 at 16:36
  • Hey guys, it's working now, i'll update the post with the solution, tks for everything – Pedro Henrique Oct 31 '14 at 16:53
  • @PedroHenrique do you feel I should delete the answer, or you can mark it as accepted? I see that it is pretty close to what your real problem was. Thanks. – alecxe Oct 31 '14 at 18:32