html - Unable to capture error message - selenium java junit -


i need capture error messages displayed, tried many methods every method throws exception --unable find element, pls code. these methods tried.also, there no id, div element. this...

<div id="webformerrors" class="text" name="errorcontent"> <div> there 4 errors: <ul> <li> did not enter value for: <b>first name</b> </li> <li> did not enter value for: <b>last name</b> </li> <li> <li>  //string errormsg; ![enter image description here][1]errormsg = hcd.findelement(by.xpath("//div[@id=webformerrors']/text()")).gettext();  // webelement divelement = hcd.findelement(by.classname("errorcontent"));  // hcd.findelement(by.name("there 4 errors:")).isdisplayed();  **string pstring = hcd.findelement(by.id("webformerrors")).gettext();         system.out.println(pstring); 

you have given classname , name wrong. classname "text" , name "errorcontent".

webelement divelement = hcd.findelement(by.classname("text")); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -