selenium in a web service throws java.lang.NoClassDefFoundError exception -
i created dynamic web project, implemented function uses selenium in it, added selenium-server-standalone-2.32.0.jar in project's buidlpath, used wizard generate web server , client. popped warning read:
the service class "test.eko3.testeko3" not comply 1 or more requirements of jax-rpc 1.1 specification, , may not deploy or function correctly. value type "org.openqa.selenium.webdriver" used via service class "test.eko3.testeko3" not have public default constructor. chapter 5.4 of jax-rpc 1.1 specification requires value type have public default constructor, otherwise jax-rpc 1.1 compliant web service engine may unable construct instance of value type during deserialization. field or property "windowhandles" on value type "org.openqa.selenium.webdriver" used via service class "test.eko3.testeko3" has data type, "java.util.set", not supported jax-rpc 1.1 specification. instances of type may not serialize or deserialize correctly. loss of data or complete failure of web service may result.
i clicked ok , continued generating server , client. when finished , tried test client displayed exception in result view:
exception: java.lang.noclassdeffounderror: org/openqa/selenium/webdriver; nested exception is: java.lang.noclassdeffounderror: org/openqa/selenium/webdriver message: java.lang.noclassdeffounderror: org/openqa/selenium/webdriver; nested exception is: java.lang.noclassdeffounderror: org/openqa/selenium/webdriver
then added same jar file web-inf/lib folder , ran again shows same exception. there other place need add jar? appreciated.
the code server below:
package test.eko3; import org.openqa.selenium.by; import org.openqa.selenium.javascriptexecutor; 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.wait; import org.openqa.selenium.support.ui.webdriverwait; public class testeko3 { public string ekobilet(string from, string to, string date) { //firefox browser instantiation webdriver driver = new firefoxdriver(); //loading url driver.get("http://www.amadeusepower.com/trek/portals/trek/default.aspx?culture=en-us"); webelement radiooneway = driver.findelement(by.id("ctl00_ctl00_ctl00_cph1_cph1_quicksearchall1_quickflightsearchcontrol1_rbflighttype_1")); radiooneway.click(); waitforpageloaded(driver); webelement fromtext = driver.findelement(by.id("ctl00_ctl00_ctl00_cph1_cph1_quicksearchall1_quickflightsearchcontrol1_txtsearch_txtfrom")); fromtext.clear(); fromtext.sendkeys(from); webelement totext = driver.findelement(by.id("ctl00_ctl00_ctl00_cph1_cph1_quicksearchall1_quickflightsearchcontrol1_txtsearch_txtto")); totext.sendkeys(to); webelement datetext = driver.findelement(by.id("ctl00_ctl00_ctl00_cph1_cph1_quicksearchall1_quickflightsearchcontrol1_txtdeparturedate_txtdate")); datetext.sendkeys(date); //sign in button identification , click webelement searchbutton = driver.findelement(by.id("ctl00_ctl00_ctl00_cph1_cph1_quicksearchall1_quickflightsearchcontrol1_btnsearch")); searchbutton.click(); string page = driver.getpagesource(); //closing browser driver.close(); return page; } public static void waitforpageloaded(webdriver driver) { expectedcondition<boolean> expectation = new expectedcondition<boolean>() { public boolean apply(webdriver driver) { return ((javascriptexecutor)driver).executescript("return document.readystate").equals("complete"); } }; wait<webdriver> wait = new webdriverwait(driver,30); try { wait.until(expectation); } catch(throwable error) { system.out.println("exception yavrum"); } } }
maybe using selenium standalone jar, not dynamic web projects in java. see http://me-ol-blog.blogspot.co.il/2013/07/using-selenium-in-java-dynamic-web.html
Comments
Post a Comment