Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

element.all locator is not printing length / count #2780

Closed
pgonaguntla opened this issue Dec 11, 2015 · 2 comments
Closed

element.all locator is not printing length / count #2780

pgonaguntla opened this issue Dec 11, 2015 · 2 comments

Comments

@pgonaguntla
Copy link

Hi,

I'm new to Protractor and currently in learning phase. We are looking to use this in the next project. In learning, I'm trying to print length and count for element.all but unfortunately runner is showing error. Could you please help me where I'm missing if any. Thank you for your support.

Code:
//
var angjspage_Basicssec = require('../page/basicssection_page.js');
var angjspage_Todolist = require('../page/todosection_object.js');
describe("AngularJS Page automation",function(){
beforeEach(function(){
browser.get("http://angularjs.org");
});

it("Verify Todo section and add Task function",function(){
var strtodoitem = 'Angular test2';

    //browser.waitForAngular();
    console.log(element.all(by.css("[ng-repeat = 'todo in todoList.todos']")).count());
    console.log(element.all(by.repeater("todo in todoList.todos")).length);
});

});

Error:
[launcher] Running 1 instances of WebDriver
Object {
closure_uid_696411893: 356,
flow_:
Object {
events_: Object {},
closure_uid_696411893: 1,
activeFrame_:
Object {
events_: Object {},
closure_uid_696411893: 335,
flow_: [Circular],
parent_: [Object],
children_: [Object],
lastInsertedChild_: [Object],
pendingTask_: null,
isLocked_: false,
isBlocked_: false,
pendingCallback: false,
pendingRejection: false,
cancellationError_: null },
runningFrame_:
Object {
events_: Object {},
closure_uid_696411893: 335,
flow_: [Circular],
parent_: [Object],
children_: [Object],
lastInsertedChild_: [Object],
pendingTask_: null,
isLocked_: false,
isBlocked_: false,
pendingCallback: false,
pendingRejection: false,
cancellationError_: null },
schedulingFrame_:
Object {
events_: Object {},
closure_uid_696411893: 335,
flow_: [Circular],
parent_: [Object],
children_: [Object],
lastInsertedChild_: [Object],
pendingTask_: null,
isLocked_: false,
isBlocked_: false,
pendingCallback: false,
pendingRejection: false,
cancellationError_: null },
shutdownTask_: null,
eventLoopTask_: null,
hold_:
{ called: false,
idleTimeout: 2147483647,
idlePrev: [Object],
idleNext: [Object],
idleStart: 8217,
onTimeout: [Function: wrapper],
repeat: [Function] },
yieldCount
: 2 },
stack
: null,
parent
:
Object {
closure_uid_696411893: 354,
flow
:
Object {
events
: Object {},
closure_uid_696411893: 1,
activeFrame
: [Object],
runningFrame
: [Object],
schedulingFrame_: [Object],
shutdownTask_: null,
eventLoopTask_: null,
hold_: [Object],
yieldCount_: 2 },
stack_: null,
parent_:
Object {
closure_uid_696411893: 352,
flow_: [Object],
stack_: null,
parent_: [Object],
callbacks_: [Object],
state_: 'pending',
handled_: true,
pendingNotifications_: false,
value_: undefined },
callbacks_: [ [Object] ],
state_: 'pending',
handled_: true,
pendingNotifications_: false,
value_: undefined },
callbacks_: null,
state_: 'pending',
handled_: false,
pendingNotifications_: false,
value_: undefined }

@NickTomlin
Copy link
Contributor

count() returns a promise (you are seeing the promise object logged out), so you will need to wait for the promise to be resolved with the actual value:

element.all(by.repeater("todo in todoList.todos")).count().then(function (size) {
  console.log(size); 
});

With that said, your question is better suited for StackOverflow or Gitter. In the future, Please ask a question there with the 'protractor' tag or post in the Gitter Channel to get help.

From the the getting help section of the README:

Please ask usage and debugging questions on StackOverflow (use the "protractor" tag) or in the Angular discussion group. (Please do not ask support questions here on Github.)

@sjelin sjelin closed this as completed Dec 11, 2015
@DeveloperChallenge
Copy link

Thanks, i worked well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants