input - Why JSF UI components are not displayed in Graphene WebDriver test browser instance? -
i wonder why jsf 2.2 ui input components not rendered in arquillian drone graphene webdriver's test browser instance. test page follows:
<?xml version="1.0" encoding="utf-8" ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"> <h:head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>login</title> </h:head> <h:body> <h:form id="loginform"> <h3>login failure</h3> <h:panelgrid columns="2"> <h:outputlabel for="username">username:</h:outputlabel> <h:inputtext id="username"/> <h:outputlabel for="password">password:</h:outputlabel> <h:inputsecret id="password" /> <h:commandbutton id="login" value="log in" /> </h:panelgrid> </h:form> </h:body> </html>
and arquillian drone test class follows:
import java.io.file; import java.io.serializable; import java.net.url; import java.util.concurrent.timeunit; import org.jboss.arquillian.container.test.api.deployment; import org.jboss.arquillian.drone.api.annotation.drone; import org.jboss.arquillian.junit.arquillian; import org.jboss.arquillian.test.api.arquillianresource; import org.jboss.shrinkwrap.api.filters; import org.jboss.shrinkwrap.api.genericarchive; import org.jboss.shrinkwrap.api.shrinkwrap; import org.jboss.shrinkwrap.api.asset.emptyasset; import org.jboss.shrinkwrap.api.asset.stringasset; import org.jboss.shrinkwrap.api.importer.explodedimporter; import org.jboss.shrinkwrap.api.spec.webarchive; import org.junit.test; import org.junit.runner.runwith; import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.webelement; import org.primefaces.model.sortorder; ------------ @runwith(arquillian.class) public class arquilliandronetest { @drone webdriver browser; @arquillianresource url deploymenturl; private static final string webapp_src = "src/main/webapp"; @deployment(testable=false) public static webarchive createdeployment() { return shrinkwrap.create(webarchive.class,"mytestwar.war") .addclass(testejb.class) .addclass(servicefacade.class).addclass(servicequeryfacade.class).addclass(abstractfacade.class) .addclass(service.class).addclass(abstractlongpkentity.class).addclass(abstractentity.class) .addclass(persistententity.class).addclass(serializable.class).addclass(persistententity.class) .addclass(sortorder.class) .merge(shrinkwrap.create(genericarchive.class).as(explodedimporter.class) .importdirectory(webapp_src).as(genericarchive.class), "/", filters.include(".*\\.xhtml$")) .addasresource("test-persistence.xml", "meta-inf/persistence.xml") .addaswebinfresource(emptyasset.instance, "beans.xml") .addaswebinfresource(new stringasset("<faces-config version=\"2.0\"/>"),"faces-config.xml") .addaswebresource(new file(webapp_src, "dos.xhtml")); } @test public void testuserloginsuccess() { browser.get(deploymenturl.toexternalform() + "/login.xhtml"); browser.manage().timeouts().implicitlywait(15, timeunit.seconds); webelement textusername=browser.findelement(by.id("username")); textusername.sendkeys("testuser"); } }
and results (on running maven test) following webdriver test browser
why jsf not rendered in test browser?
from comment @balusc, found clue , solved problem i.e. inclusion of either production web.xml or testing web.xml file test war. added production web.xml follows in test class , worked me:
--------------- @deployment(testable=false) public static webarchive createdeployment() { return shrinkwrap.create(webarchive.class,"mytestwar.war") .addclass(testejb.class) .addclass(servicefacade.class).addclass(servicequeryfacade.class).addclass(abstractfacade.class) .addclass(service.class).addclass(abstractlongpkentity.class).addclass(abstractentity.class) .addclass(persistententity.class).addclass(serializable.class).addclass(persistententity.class) .addclass(sortorder.class) .merge(shrinkwrap.create(genericarchive.class).as(explodedimporter.class) .importdirectory(webapp_src).as(genericarchive.class), "/",filters.include(".*\\.(jsf|xhtml|html|css|js|png|jpg|xml)$")) .addasresource("test-persistence.xml", "meta-inf/persistence.xml") .addaswebinfresource(emptyasset.instance, "beans.xml") .addaswebinfresource(new file(webapp_src,"web-inf/faces-config.xml")) .setwebxml(new file(webapp_src,"web-inf/web.xml")) .addaswebresource(new file(webapp_src, "dos.xhtml")); } ----------------------------
Comments
Post a Comment