Following the HTML code provided below, there is a table containing a list of test site links with a delete button next to each test site.
/* Element locators in the table */
var testSiteLinks = element.all(by.css('a[ui-sref^="testpages"]'));
var deleteBtnCssStart = "body > div.container > div > div > div > div > div > div:nth-child(2) > table > tbody > tr:nth-child(";
var deteletBtnCssEnd = ") > td > button";
var testSite = {
deleteSite: function(siteName){
testSiteLinks.each(function(element,index){
var temp = index;
element.getText().then(function(text) {
temp++;
var patt = new RegExp(siteName);
if(patt.test(text)){
// CSS locator for delete button corresponding to the test site
var test = deleteBtnCssStart + temp + deteletBtnCssEnd;
// Click on the delete button, but this step is failing with the error "TypeError: object is not a function"
element(by.css(test)).click();
}
});
});
}
I have attempted to add a function as depicted above to search for a test site in the table and delete the site if it exists in the table. However, the test is failing when trying to click on the delete button, displaying the error "TypeError: object is not a function". Could you please provide guidance on any corrections needed?
Please see the HTML code for the table along with the test site links below.
<table class="table card">
<thead></thead>
<tbody>
<!-- ngRepeat: site in Sites --><tr ng-repeat="site in Sites" class="ng-scope">
<td>
<button ng-hide="role.DeletingSite===true" ng-click="role.DeletingSite=true" class="delSite pull-right btn btn-sm btn-danger" tabindex="0" aria-hidden="false">Delete</button>
<div ng-show="role.DeletingSite===true" class="pull-right ng-hide" aria-hidden="true">
<a ng-click="role.DeletingSite=false" class="btn btn-sm btn-default pull-right" tabindex="0">Cancel</a>
<a ng-click="deleteSite(site)" class="reallyDelete btn btn-sm btn-danger pull-right " tabindex="0">Delete</a>
</div>
<a ui-sref="testpages({id:site.id, name:site.name, host:site.host, httpsSupported:site.httpsSupported})" class="ng-binding" href="#/testsite/pages/40288a884cdaa49a014cdbfb08270003/testsite/testsite/true ">testsite (testsite)</a>
</td>
</tr><!-- end ngRepeat: site in Sites --><tr ng-repeat="site in Sites" class="ng-scope">
<td>
<button ng-hide="role.DeletingSite===true" ng-click="role.DeletingSite=true" class="delSite pull-right btn btn-sm btn-danger" tabindex="0" aria-hidden="false">Delete</button>
<div ng-show="role.DeletingSite===true" class="pull-right ng-hide" aria-hidden="true">
<a ng-click="role.DeletingSite=false" class="btn btn-sm btn-default pull-right" tabindex="0">Cancel</a>
<a ng-click="deleteSite(site)" class="reallyDelete btn btn-sm btn-danger pull-right " tabindex="0">Delete</a>
</div>
<a ui-sref="testsitepages({id:site.id, name:site.name, host:site.host, httpsSupported:site.httpsSupported})" class="ng-binding" href="#/test/pages/40288a884cd57e14014cd60701890001/TestSite.org/testsite.org/false ">Testsite.org (testsite.org)</a>
</td>
</tr><!-- end ngRepeat: site in Sites -->
</tbody>
</table>