Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在java中通过jsp显示的web驱动程序中断言java异常?_Java_Jsp_Selenium Webdriver - Fatal编程技术网

如何在java中通过jsp显示的web驱动程序中断言java异常?

如何在java中通过jsp显示的web驱动程序中断言java异常?,java,jsp,selenium-webdriver,Java,Jsp,Selenium Webdriver,我想在web驱动程序中断言异常消息,我通过jsp显示异常消息,如下所示 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%@ page contentType="text/html;charset=UTF-8" language="java" %>

我想在web驱动程序中断言异常消息,我通过jsp显示异常消息,如下所示

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">       
<%@ page contentType="text/html;charset=UTF-8" language="java" %>     
<%@ page isErrorPage="true" import="java.io.PrintWriter" %>      

<html>      
<head>    
<title>Online Accounting Software</title>     
  <link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />    
</head>     
<body>     

  <div class="wrapper">    
<div class="page-container">     
    <jsp:include page="/header.jsp" />    
    <jsp:include page="/mainMenuHeader.jsp" />     
 <div class="blocktenant">    
  <%     
      // unwrap ServletExceptions.    
      while (exception instanceof ServletException) {      
        exception = ((ServletException) exception).getRootCause();    
      }

      // print stack trace.     
      out.println(exception.getMessage());    
  %>   
  </div>   
  </div>     
</div>    

</body></html>      

在线会计软件
但是我无法使用driver.getPageSource().contains(containString)来断言异常消息;我的消息是“com.veersoft.gwt.shared.VsException:名称'alice bob'已存在。请提供其他名称”

任何建议都很好

谢谢,
MSNaidu.

我建议直接捕捉以下信息:

String t = driver.findElement(By.cssSelector("div.page-container div.blocktenant")).getText();

Assert.assertEquals(t,message);
你有html格式的渲染吗?就像浏览器显示的一样