我想知道为什么我的 JSF 2.2 UI 输入组件没有在我的 Arquillian Drone Graphene WebDriver 的测试浏览器实例中呈现。我的测试页面如下:
<?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>
我的 Arquillian 无人机测试课程如下:
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");
}
}
并且所有这些结果(在运行 maven 测试中)进入以下 WebDriver 测试浏览器
为什么 JSF 没有在这个测试浏览器中呈现?