Protractor- element all count returning zero - angularjs

Following is our html page content
<div class="list-container ng-scope" ng-if="nodes.viewType == 'list'">
<table>
<tbody class="ng-scope ng-isolate-scope" ng-repeat="node in nodes.search.results track by node._id" content-list-row="" ct-node="node" access-parent="true" view-source="search">
<tr id="listrow-590828ac3a058f6a908976cc" class="listrow ng-scope" ng-if="!node.isContainer" ng-class="{'editing-tags': editingTags}" ui-draggable="$parent.canDrag()" drag-channel="N" drag="node" draggable="true">
<td class="background_2_pdf" ng-class="('background_'+node.type +'_'+(node.attachments[0].mimeType | mimeTypeToGroup))" width="2px"></td>
<td style="padding: 8px 5px 8px 10px" width="30px" align="center">
<td class="node-name" ng-style="getNameWidth()" style="cursor: pointer; min-width: 250px;" colspan="1" nowrap="">
<td class="hidden-xs ng-scope" ng-if="$parent.viewSource =='search'" style="padding-left: 2px; padding-right: 2px" nowrap="">
<span class="ng-scope" ng-if="$parent.node.search.highlight.n_searchContent"> </span>
<span class="fa fa-file-text ng-scope" style="color:#618FE7" ng-if="$parent.node.search.highlight.n_searchContent" popover-trigger="mouseenter" uib-popover-html="$parent.node.search.highlight.n_searchContent[0]"></span>
</td>
<td class="hidden-xs ng-scope" style="padding-left: 2px; padding-right: 2px" ng-if="!editingTags && !editingName" nowrap="">
<td class="node-updated hidden-xs ng-binding ng-scope" style="padding-left: 2px; padding-right: 2px" ng-if="!editingTags && $parent.viewSource !=='metadata'" nowrap="">Updated 85 days ago</td>
<td class="node-owner hidden-xs hidden-sm ng-binding ng-scope" style="padding-left: 2px; padding-right: 2px" ng-if="!editingTags && $parent.viewSource !=='metadata'" nowrap="">Sagar Ladwa</td>
<td class="node-date hidden-xs hidden-sm ng-binding ng-scope" style="padding-left: 2px; padding-right: 2px" ng-if="!editingTags && audit.activity === 'create' && $parent.viewSource !=='metadata'" ng-repeat="audit in node.audit" nowrap="">02/05/2017</td>
<td class="node-options ng-scope" ng-if="!editingTags && !editingMetaTags" nowrap="">
</tr>
</tbody>
<tbody class="ng-scope ng-isolate-scope" ng-repeat="node in nodes.search.results track by node._id" content-list-row="" ct-node="node" access-parent="true" view-source="search">
<tbody class="ng-scope ng-isolate-scope" ng-repeat="node in nodes.search.results track by node._id" content-list-row="" ct-node="node" access-parent="true" view-source="search">
<tbody class="ng-scope ng-isolate-scope" ng-repeat="node in nodes.search.results track by node._id" content-list-row="" ct-node="node" access-parent="true" view-source="search">
<tbody class="ng-scope ng-isolate-scope" ng-repeat="node in nodes.search.results track by node._id" content-list-row="" ct-node="node" access-parent="true" view-source="search">
<tbody class="ng-scope ng-isolate-scope" ng-repeat="node in nodes.search.results track by node._id" content-list-row="" ct-
In this page we have multiple tbody's. My requirement is to get all class="fa fa-file-text ng-scope" from all tbody and iterate. Following samples i tried get count/length of element
but all giving either 0 or no result
var list1= element.all(by.css('.fa fa-file-text ng-scope'));
list1.count().then(function (size){
console.log('------------------------------'+size);
});
and
element.all(by.css('.fa fa-file-text ng-scope')).count().then(function(size){
console.log('------------------------------'+size);
});
and
element.all(by.css('.fa fa-file-text ng-scope')).map(function(files){
return files;
}).then(function(files1){
console.log('------------------------------'+files1.length);
});

Related

django for loop item list value check

I want to check if all for loop objects from below model and template have either signed or rejected the record. i.e. can you tell me how to check approve or reject field value for moc.verifiers.all list members?
For instance I have a three verifiers in the record. I want to based on their approve or reject change record status. Could you please give me a hint how I can do it.
Verifier
class Verifier(models.Model):
moc = models.ForeignKey(Moc, related_name='verifiers', on_delete=models.CASCADE, default='1')
verifier_group = models.CharField(max_length=36, blank=True, null=True)
verifier_name = models.ForeignKey(User, blank=True, null=True, on_delete=models.CASCADE,)
verify_due = models.DateField(blank=True, null=True)
approve = models.BooleanField(default=False)
reject = models.BooleanField(default=False)
signoff_date = models.DateField(auto_now_add=True)
note = models.TextField(max_length=256, blank=True)
def __str__(self):
return str(self.id)
Template
{% for obj in moc.verifiers.all %}
<tr style="text-align: center; FONT-SIZE: 7pt; BORDER-TOP: lightgrey 1px solid; HEIGHT: 25px; FONT-FAMILY: Verdana; BORDER-RIGHT: lightgrey 1px solid; BORDER-BOTTOM: lightgrey 1px solid; COLOR: #333333; BORDER-LEFT: lightgrey 1px solid"
valign="middle">
<td>
<form method="post" action="{% url 'delete_verifier' obj.pk %}">
{% csrf_token %}
<a href="{% url 'add_verify_signoff' obj.pk %}" target="_blank" type="button"
class="col-4 btn btn-primary p-1">
<i class="bi bi-pencil-square"></i>
</a>
<button type="button" class="col-4 btn btn-danger p-1" style="color: whitesmoke;" data-bs-toggle="modal"
data-bs-target="#delete-verifier"><i class="bi bi-trash"></i></button>
<!-- Modal -->
<div class="modal fade" id="delete-verifier" data-bs-backdrop="static" data-bs-keyboard="false"
tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" style="background-color: #e6990a; height: 30px;">
<h5 class="modal-title" id="staticBackdropLabel" style="color: whitesmoke;">Notification
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p style="font-size: medium;">Are you sure that you want to delete this verifier?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary">Confirm</button>
</div>
</div>
</div>
</div>
</form>
{% endif %}
</td>
<td style="WIDTH: 12%">{{ forloop.counter }}{{ obj.verifier_group }}</td>
<td style="WIDTH: 110px">{{ obj.verifier_name }}</td>
<td style="WIDTH: 110px">{{ obj.verify_due|date:'d M Y' }}</td>
{% if obj.approve %}
<td style="WIDTH: 20px"><input class="form-check-input-bg" type="checkbox" value="{{ obj.approve }}" checked
onclick="return false"></td>
<td style="WIDTH: 20px"><input class="form-check-input-bg" type="checkbox" value="{{ obj.reject }}"
onclick="return false">
{% elif obj.reject %}
<td style="WIDTH: 20px"><input class="form-check-input-bg" type="checkbox" value="{{ obj.approve }}"
onclick="return false"></td>
<td style="WIDTH: 20px"><input class="form-check-input-bg" type="checkbox" value="{{ obj.reject }}" checked
onclick="return false">
</td>
{% else %}
<td style="WIDTH: 20px">
<input class="form-check-input-bg" type="checkbox" value="" disabled>
</td>
<td style="WIDTH: 20px">
<input class="form-check-input-bg" type="checkbox" disabled onclick="return false">
</td>
{% endif %}
<td style="WIDTH: 90px">{{ obj.signoff_date|date:'d M Y'}}</td>
<td style="WIDTH: 200px">{{ obj.verifier_name }}</td>
<td style="WIDTH: 200px; text-align: justify;">{{ obj.note }}</td>
{% empty %}
<td colspan="8" style="WIDTH: 130px">No verifiers assigned yet...
</td>
</tr>
{% endfor %}

Getting Error while doing selenium automation for Dojo :Exception in thread "main" org.openqa.selenium.TimeoutException:?

How to derive the path for the following which in DOJO? It is a dropdown. There are many elements in this page but some elements like this is not getting identified inspite of giving the correct xpath.
Code for selecting the dropdown arrow:
<div class=" dijitSelect dijitValidationTextBox dijitSelectError dijitValidationTextBoxError dijitError dijitSelectHover dijitValidationTextBoxHover dijitSelectErrorHover dijitValidationTextBoxErrorHover dijitErrorHover dijitHover" lang="en" widgetid="accountType" aria-expanded="false">
<table id="accountType" class="dijit dijitReset dijitInline dijitLeft dijitSelect dijitValidationTextBox dijitDownArrowButton" cellspacing="0" cellpadding="0" aria-haspopup="true" role="listbox" data-dojo-attach-point="_buttonNode,tableNode,focusNode" style="-moz-user-select: none;" tabindex="0" aria-required="true" aria-labelledby="addAccountRecordMain_accountType">
<tbody role="presentation">
<tr role="presentation">
<td class="dijitReset dijitStretch dijitButtonContents" role="presentation">
<td class="dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton dijitArrowButtonContainer" role="presentation" data-dojo-attach-point="titleNode">
The element in the drop down arrow:
<div id="accountType_menu" class="dijit dijitMenu dijitReset dijitSelectMenu dijitValidationTextBoxMenu hdxSelectDropDownPopup accountTypePopup dijitMenuActive" style="overflow: hidden; top: 0px; visibility: visible; max-height: none; width: 331px; height: 270px;" role="presentation" widgetid="accountType_menu" tabindex="0">
<table class="dijitReset dijitMenuTable" cellspacing="0" data-dojo-attach-event="onkeypress:_onKeyPress" tabindex="0" role="listbox" style="width: 100%;">
<tbody class="dijitReset" data-dojo-attach-point="containerNode">
<tr id="dijit_MenuItem_43" class="dijitReset dijitMenuItem" tabindex="-1" role="option" data-dojo-attach-point="focusNode" aria-labelledby="dijit_MenuItem_43_text dijit_MenuItem_43_accel" style="-moz-user-select: none;" aria-disabled="false" widgetid="dijit_MenuItem_43">
<tr id="dijit_MenuItem_44" class="dijitReset dijitMenuItem dijitMenuItemHover dijitHover dijitMenuItemFocused dijitMenuItemHoverFocused dijitHoverFocused dijitFocused dijitMenuItemSelected" tabindex="0" role="option" data-dojo-attach-point="focusNode" aria-labelledby="dijit_MenuItem_44_text dijit_MenuItem_44_accel" style="-moz-user-select: none;" aria-disabled="false" widgetid="dijit_MenuItem_44">
<td class="dijitReset dijitMenuItemIconCell" role="presentation">
<td id="dijit_MenuItem_44_text" class="dijitReset dijitMenuItemLabel" data-dojo-attach-point="containerNode" colspan="2">FA-FA</td>
<td id="dijit_MenuItem_44_accel" class="dijitReset dijitMenuItemAccelKey" data-dojo-attach-point="accelKeyNode" style="display: none"/>
The various combinations that I have used for selecting this element :
->
drive.findElement(By.xpath("//div[#id='accountType_dropdown']/div/div[1]/div/table/tbody/tr[2]/td[2]")).click();
drive.findElement(By.xpath("//td[#id='dijit_MenuItem_44_text'][contains(text(),'FA-FA')]")).click();
->
drive.findElement(By.xpath("//div/table[#id='accountType']/tbody/tr/td/div[2]")).click();
drive.findElement(By.xpath("//table[#id='accountType']/tbody/tr/td[2]")).click();
The Error message I am getting:
Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: Cannot click on element (WARNING: The server did not provide any stacktrace information)
I even tried using Webdriver wait and Javascript executer but still not working.

Angularjs-probelm dont work $compile after get response of ajax

i created directive for making print page.this directive have template page that included button and print template(this have ngRepeat on Result object).print button was clicked fire "click" funciton in Controller of directive then ajax request send to server for get array of object that fill print tamplate.
Mainpage.html
<div ng-class="{'btn':true,'btn-warning':true,'disabled':disableBtn}" data-toggle="modal"
ng-click="getdetail=true;" data-target="#detailModal">order detail</div>
<print-order disable-btn="disableBtn" order="selectedItem"></print-order>
print.template.html
<a ng-click="ctrl.click()" ng-class="{'btn':true,'btn-info':true,'disabled':ctrl.disableBtn}" >
print
<i class="fa fa-print"></i>
</a>
<div id="printSection">
<table style="width: 100%;font:13px tahoma;" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th style="border-bottom: 3px solid black;">
<p>number: </p>
{{ctrl.order.fldTracking}}
</th>
<th>
<img src="/images/receipt-logo.png" alt="">
</th>
<th style="border-bottom: 3px solid black;">
<p>code :</p>
<p> {{ctrl.order.customer.fldMobilePhone}}
<br> {{ctrl.order.fldAtFA.split("-")[0]}}
</p>
</th>
</tr>
</thead>
<tbody>
<tr style="border-bottom: 3px solid black;">
<td colspan="3" style="padding: 10px;line-height: 20px;">
cutomer : {{ctrl.order.customerAddress.fldContactName }}
<br /> address: {{ctrl.order.customerAddress.fldAddress }}
<br/>mobile : {{ctrl.order.customerAddress.fldMobilePhone}}
<br/> phone : {{ctrl.order.customerAddress.fldTelephone}} </td>
</tr>
</tbody>
</table>
<h1>{{ctrl.title}}</h1>
<table dir="rtl" width="100%" border="0" cellspacing="0" cellpadding="0" align="center" style="margin-top:20px;border-top:2px solid #000000;;border-bottom:2px solid #000000;border-color: #000000">
<tbody>
<tr>
<td width="40%" style="padding-right:10px;font-size: 10px" align="right">name</td>
<td width="20%" style="font-size: 10px" align="center">number</td>
<td width="20%" style="font-size: 10px" align="center">price</td>
<td width="25%" style="font-size: 10px" align="right">price</td>
</tr>
<tr ng-repeat="item in ctrl.Components track by $index">
<td style="padding-right:10px;font-size: 9px">
{{item.offer.fldTitle}}<br>
</td>
<td style="font-size: 12px" align="center">{{item.fldQty}}</td>
<td style="font-size: 10px" align="center">{{item.fldUnitPrice}}</td>
<td style="font-size: 10px;padding: 5px">{{item.fldTotalPrice}}</td>
</tr>
</tbody>
</table>
</div>
printdirective.js
myApp.directive("printOrder",["$window","orderService","$timeout","$compile",function($windows,orderService,$timeout,$compile){
return{
restrict:"AE",
bindToController:{
disableBtn:"=",
order:"="
},
templateUrl:"/Widgets/printOrder.template.html",
transclude: true,
scope:true,
controllerAs:"ctrl",
controller:function(){
this.click=function(){
var popupWinindow =$windows.open("", '_blank', 'width=300,height=500');
orderService.getOrderDetail(this.order.id)
.then(function(result){
this.Components=result;
popupWinindow.document.open();
var el=angular.element("#printSection")
$compile(el)(this);
$timeout(function(){
// console.log(el.html());
popupWinindow.document.write(
`<html>
<head></head>
<body style="direction: rtl;">`+el.html()+` </body>
</html>`);
popupWinindow.document.close();
},500)
});
}
},
}
}])
when i clicked on print button .id of order send to directive then detail of order request of server with ajax that this should fill "#printSection" of template by $compile but this dont binding and Components property is empty.
but this dont binding and Components property is empty.
You cannot call $compile with this, in your case $compile(el)(this);
this != scope
Use:
controller:function($scope){
$compile(el)($scope);
}
Small Demo
Is it typo? var el=angular.element("#printSection")
Did you mean something like:
var warapper = document.querySelector('#printSection');
angular.element(warapper); //...

Combo box with multiple checkbox in bootstrap

In bootstrap how to use comboBox with multiple checkbox option as in the attached image.
I used multiple checkbox option in dropdown list as below, but i do not wish drop down list with checkbox, instead wish to have like the image attached.
<select multiple="multiple"> .... </select>
From the below way i got the solution
<table>
<tr>
<td>
<div
style="max-height: 350px; overflow-y: scroll; width: 375px;background: white;"
class="scrollbar style-2">
<table class="table">
<thead align="center">
<tr>
<th style="text-align: center;background: #5cb85c;color : white;">List</th>
<th style="background: white;background: #5cb85c;color : white;"></th>
</tr>
</thead>
<tbody style="background: white;">
<%
for (int i = 0; i < 10; i++) {
%>
<tr style="border: 0">
<td style="border: 0">
<div class="[ form-group ]">
<input type="checkbox" name="fancy-checkbox-default_p3_ii<%=i%>"
id="fancy-checkbox-default_p3_ii<%=i%>" autocomplete="off" />
<div class="[ btn-group ]">
<label for="fancy-checkbox-default_p3_ii<%=i%>"
class="[ btn btn-success ]" style="top: 5px;"> <span
class="[ glyphicon glyphicon-ok ]"></span> <span> </span>
</label> <label for="fancy-checkbox-default_p3_ii<%=i%>"
class="[ btnCustom active ]"> Default Checkbox<%=i%>
</label>
</div>
</div>
</td>
</tr>
<%
}
%>
</tbody>
</table>
</div>
</td>
</tr>
</table>

Not able to enter text in CKeditor

I have too many ck editors(wysiwyg) in single page which are embedded in iframes. How do I switch to frame and send text to it. All frames have same classnames. I am using C#. If you are not able to view the image, let me know. I will send the code
Below is my code:
IWebElement actioninputissue = driver.FindElement(By.XPath(".//iframe[#class='cke_wysiwyg_frame'][1]"));
driver.SwitchTo().Frame(actioninputissue);
actioninputissue.SendKeys("Helllo");
I am attaching the code.
Edit 1
Thanks you so much for your reply!.
code for two ckeditors and I have also attached screenshot
Code<tr id="actionIssueRow" class="Controls">
<th valign="top">
<div id="issueLabel">
</th>
<td colspan="3">
<textarea id="actrpnlIssueInputissue" class="wide_input richtext" name="issue" rows="3" cols="84" style="line-height: 14px; visibility: hidden; display: none;"></textarea>
<div id="cke_actrpnlIssueInputissue" class="cke_1 cke cke_reset cke_chrome cke_editor_actrpnlIssueInputissue cke_ltr cke_browser_gecko" lang="en" aria-labelledby="cke_actrpnlIssueInputissue_arialbl" role="application" dir="ltr" style="width: 500px;">
<span id="cke_actrpnlIssueInputissue_arialbl" class="cke_voice_label">Rich Text Editor, actrpnlIssueInputissue</span>
<div class="cke_inner cke_reset" role="presentation">
<span id="cke_1_top" class="cke_top cke_reset_all" style="height: auto; -moz-user-select: none;" role="presentation">
<div id="cke_1_contents" class="cke_contents cke_reset" role="presentation" style="height: 170px;">
<span id="cke_52" class="cke_voice_label">Press ALT 0 for help</span>
<iframe class="cke_wysiwyg_frame cke_reset" frameborder="0" src="" style="width: 100%; height: 100%;" title="Rich Text Editor, actrpnlIssueInputissue" aria-describedby="cke_52" tabindex="0" allowtransparency="true">
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<body class="cke_editable cke_editable_themed cke_contents_ltr cke_show_borders" contenteditable="true" spellcheck="true">
<br _moz_editor_bogus_node="TRUE">
</body>
</html>
</iframe>
</div>
<span id="cke_1_bottom" class="cke_bottom cke_reset_all" role="presentation" style="-moz-user-select: none;">
<span id="cke_1_resizer" class="cke_resizer cke_resizer_ltr" onmousedown="CKEDITOR.tools.callFunction(0, event)" title="Resize">◢</span>
</span>
</div>
</div>
<input id="actrpnlIssueInputissue_txt" type="hidden" value="" name="issue_txt">
</td>
</tr>
<tr class="Controls">
<th valign="top"> </th>
<td colspan="4"> </td>
</tr>
<tr class="Controls">
<th valign="top">
<td colspan="4">
<textarea id="actrpnlActionDescriptionInputactn" class="wide_input richtext" name="actn" rows="3" cols="84" style="line-height: 14px; visibility: hidden; display: none;"></textarea>
<div id="cke_actrpnlActionDescriptionInputactn" class="cke_2 cke cke_reset cke_chrome cke_editor_actrpnlActionDescriptionInputactn cke_ltr cke_browser_gecko" lang="en" aria-labelledby="cke_actrpnlActionDescriptionInputactn_arialbl" role="application" dir="ltr" style="width: 500px;">
<span id="cke_actrpnlActionDescriptionInputactn_arialbl" class="cke_voice_label">Rich Text Editor, actrpnlActionDescriptionInputactn</span>
<div class="cke_inner cke_reset" role="presentation">
<span id="cke_2_top" class="cke_top cke_reset_all" style="height: auto; -moz-user-select: none;" role="presentation">
<div id="cke_2_contents" class="cke_contents cke_reset" role="presentation" style="height: 170px;">
<span id="cke_92" class="cke_voice_label">Press ALT 0 for help</span>
<iframe class="cke_wysiwyg_frame cke_reset" frameborder="0" src="" style="width: 100%; height: 100%;" title="Rich Text Editor, actrpnlActionDescriptionInputactn" aria-describedby="cke_92" tabindex="0" allowtransparency="true">
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<body class="cke_editable cke_editable_themed cke_contents_ltr cke_show_borders" contenteditable="true" spellcheck="true">
<p>
</body>
</html>
</iframe>
</div>
<span id="cke_2_bottom" class="cke_bottom cke_reset_all" role="presentation" style="-moz-user-select: none;">
</div>
</div>
<input id="actrpnlActionDescriptionInputactn_txt" type="hidden" value="" name="actn_txt">
</td>

Resources