[AngularJS] Re: Protractor test trying to find element in table (async)

2020-02-07 Thread Mohammed Chand Kousar Sayed
I am also in same situation, My function returns undefined instead cell 
value, any help is appreciated

async verifyCreateAuditReport(FieldValue?: string): Promise {

var deferred = protractor.promise.defer();
browser.logger.info("Verify Data on Create Audit Report");
await browser.wait(element(by.xpath("//td/span['Name:']")).
isDisplayed(), 3);

await this.auditCriteriaReport.all(by.tagName('tr')).then(function (
rows) {
browser.logger.info("Row Count::" + rows.length);
rows.forEach(function (row: ElementFinder) {
row.all(by.tagName('td > span')).then(function (cols) {
browser.logger.info("Column Count::" + cols.length);

if (cols.length > 0) {
cols.forEach(function (col: ElementFinder) {
col.getText().then(function (columnText) {
if (columnText == FieldValue) {

//browser.logger.info("Column Text is::" + columnText);
//return Promise.resolve(columnText);
return columnText;


}
});

});
}

});
});
});

}

On Friday, 28 August 2015 18:53:05 UTC+5:30, Jens Hoffmann wrote:
>
> Hello, 
>
>
> *I am trying to write a protractor test which check for the existence of an 
> table element. *
>
> *If the element doesn't exist in the table, the test should be successful.*
>
> *But the promise never resolves. I hope you can help me out. *
>
>
> *HTML:*
>
>
> *
> ...
> 
> shippingcosts
> 
> ...
> *
>
>
>
> Page Object: 
>
> FreeShippingPO.prototype = Object.create({}, {
> myelement: {
> get: function () {
> function getShippingCosts() {
> var deferred = protractor.promise.defer();
>
> element.all(by.css('table tr')).each(function (element, 
> index) {
> if(element.getText() === 'shippingcost') {
> deferred.resolve(true);
> }
> });
> return deferred.promise;
> }
> return getShippingCosts();
> }
> }
> });
>
>
> describe('free shipping costs', function () {
> it('should not have table cell with "shipping costs"', function () {
> browser.get('http://localhost:/#/shoppingCart#12314313121231');
> expect(po.myelement).to.be.false;
> });
> });
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/5b38c437-c8ca-4f1a-86ba-05f927756837%40googlegroups.com.


[AngularJS] Re: Protractor test trying to find element in table (async)

2015-08-28 Thread Jens Hoffmann
sorry forgot an 's' in shippingcosts

Am Freitag, 28. August 2015 15:23:05 UTC+2 schrieb Jens Hoffmann:

 Hello, 


 *I am trying to write a protractor test which check for the existence of an 
 table element. *

 *If the element doesn't exist in the table, the test should be successful.*

 *But the promise never resolves. I hope you can help me out. *


 *HTML:*


 *table
 ...
 tr ng-hide=vm.noShippingCosts
 tdshippingcosts/td
 /tr
 ...
 /table*



 Page Object: 

 FreeShippingPO.prototype = Object.create({}, {
 myelement: {
 get: function () {
 function getShippingCosts() {
 var deferred = protractor.promise.defer();

 element.all(by.css('table tr')).each(function (element, 
 index) {
 if(element.getText() === 'shippingcosts') {
 deferred.resolve(true);
 }
 });
 return deferred.promise;
 }
 return getShippingCosts();
 }
 }
 });


 describe('free shipping costs', function () {
 it('should not have table cell with shipping costs', function () {
 browser.get('http://localhost:/#/shoppingCart#12314313121231');
 expect(po.myelement).to.be.false;
 });
 });



-- 
You received this message because you are subscribed to the Google Groups 
AngularJS group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.