How to assert java exception in web driver which is displaying through jsp in java? -
i want assert exception message in web driver, display exception message through jsp below.
<!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>
but not able assert exception message using driver.getpagesource().contains(containstring); , message "com.veersoft.gwt.shared.vsexception: name 'alice bob' exists. provide different name"
any suggestions great.
thanks, msnaidu..
i suggest catch directly message :
string t = driver.findelement(by.cssselector("div.page-container div.blocktenant")).gettext(); assert.assertequals(t,message);
have rendenring in html ? browser displays.
Comments
Post a Comment