1

Automation framework won't proceed in executing steps at .feature file after Chrome browser was opened (then just closes after)

GenericStepImplementation.java Codes

@Before
public void setUp() throws ConfigurationException, org.apache.commons.configuration.ConfigurationException
{
    System.setProperty("webdriver.chrome.ChromeDriver","C:\\Automation\\Webdrivers\\chromedriver.exe");
    driver = new ChromeDriver();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    driver.manage().window().maximize();
    config = new XMLConfiguration("sample-object-config.xml");
}

RunAutoTest.java Codes

package test_runner;

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
glue={"code_bindings"},
features="src/test/resources/features", 
plugin = {"pretty", "html:target/cucumber-html-report"})

public class RunAutoTest {

}

Sample.feature

Feature: Automation Test

@Login-Successful
Scenario: Login (Successful)
Given I go to "www.yahoo.com" URL
    Then I enter "m@yahoo.com" into "login.username" field and click tab
    Then I enter "1234567890" into "login.password" text field
    Then I clicked on "login.loginlink" login button
    Then I wait for "15" seconds
    And I will capture the page named "Login-Successful"

After running as JUnit Test, Chrome browser was opened but doesn't execute steps in Sample.feature file. Console also displays:

*Feature: Automation Test
Starting ChromeDriver 2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387) on port 11795
Only local connections are allowed.
Jan 07, 2019 6:00:53 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
[31mFailure in before hook:[0m[31mGenericStepImplementation.setUp()[0m
[31mMessage: [0m[31mjava.lang.NoClassDefFoundError: org/apache/commons/collections/CollectionUtils
    at org.apache.commons.configuration.XMLConfiguration.constructHierarchy(XMLConfiguration.java:640)
    at org.apache.commons.configuration.XMLConfiguration.constructHierarchy(XMLConfiguration.java:635)
    at org.apache.commons.configuration.XMLConfiguration.initProperties(XMLConfiguration.java:596)
    at org.apache.commons.configuration.XMLConfiguration.load(XMLConfiguration.java:1009)
    at org.apache.commons.configuration.XMLConfiguration.load(XMLConfiguration.java:972)
Loïc Le Doyen
  • 975
  • 7
  • 16

3 Answers3

0

You need to change the keyword within the System.setProperty line from ChromeDriver to driver i.e. change:

System.setProperty("webdriver.chrome.ChromeDriver","C:\\Automation\\Webdrivers\\chromedriver.exe");

To:

System.setProperty("webdriver.chrome.driver","C:\\Automation\\Webdrivers\\chromedriver.exe");
                             only ^^^driver^^^
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

https://docs.oracle.com/javase/7/docs/api/java/lang/NoClassDefFoundError.html

This exception happens when the class existed during compilation, but doesn't exist in runtime.

Please ensure that your classpath contains org/apache/commons/collections/CollectionUtils. Probably library commons-collections is absent in classpath.

Mikhail Kopylov
  • 2,008
  • 5
  • 27
  • 58
-1

Just change the System.setProperty("webdriver.chrome.ChromeDriver","C:\\Automation\\Webdrivers\\chromedriver.exe");