Today I've found nice example of how to build own test automation framework for web apllication using Selenium Webdriver, and get nice and easy understanding code and architecture. This example demonstrated using of Yandex Htmlelements framework. But when I tried to launch my first simple example with this framework, I've got one permanent problem. It's name "NoClassDefFoundError".
Stacktrace is next:
java.lang.NoClassDefFoundError: org/apache/commons/lang/WordUtils
at ru.yandex.qatools.htmlelements.utils.HtmlElementUtils.splitCamelCase(HtmlElementUtils.java:134)
at ru.yandex.qatools.htmlelements.utils.HtmlElementUtils.getElementName(HtmlElementUtils.java:121)
at ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementDecorator.decorate(HtmlElementDecorator.java:60)
at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:112)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:104)
at calculator.MainPage.<init>(MainPage.java:18)
at calculator.Test1.Test(Test1.java:31)
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:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:125)
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:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.WordUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
In current application I use Selenium 2.46 + Htmlelements 1.14 + Latest TestNG. Also I have earlier Htmlelements library (1.11) and Selenium 2.48. I tried to launch my example with different combinations of libraries versions. Also I used different ways for annotation of my html blocks represented by appropriate classes, and intialize my page object using such methods as
HtmlElementLoader.populatePageObject(this, driver);
or
PageFactory.initElements(new HtmlElementDecorator(driver), this);
which are suggested in oficial tutorials. But result is always the same: I always get NoClassDefFoundError on invokation of above methods.
You are missing the commons-lang package on your classpath. If you use a dependency manager like maven this will be taken care of for you, otherwise download the jar and add it to your lib folder.