- Get text which are in between tags DOM
<div id="div_ResultMessage" class="AlertmsgDiv">
<div id="lblSuccessMessage" class="alert alert-success alert-dismissable">
<div class="fa fa-check-square-o"></div>
<button type="button" class="close" data-toggle="tooltip" title="Close" data-dismiss="alert" aria-hidden="true">×</button>
Pur. Requisition No. Acc000056Zip created successfully
<spam class="DivPrint">
<a onclick="window.open('/ZipERP/CommonLayout/PrintPurchaseRequisition?id=769e9c10-7a5f-4205-920e-6f967f18811e')" href="#" class="fa fa-print" data-toggle="tooltip" title="Print">
</a>
</spam>
</div>
</div>
I want to get this text if you can see it in DOM Pur. Requisition No. Acc000056Zip created successfully
I have tried fetching the text and store it in a var
var str = "";
str = element(by.id('#lblSuccessMessage')).getAttribute('value');
and also this:
var str = "";
str = element(by.id('#lblSuccessMessage')).getText().then(function(text){
console.log(text);
return text;
});
Actually I am making a purchase requistion and there is alert which generates the Purchase requistition no but it contains Pr. no but surrounded with texts for that I am applying regEx
and it says str.match()
is not a function
.
For regEx
I have tried this
prno = str.match(/ Pur. Requisition No. Acc(\d+)/i)[0];