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

Allow to query the DOM with static methods. #298

Open
bitplanets opened this issue Dec 15, 2014 · 6 comments
Open

Allow to query the DOM with static methods. #298

bitplanets opened this issue Dec 15, 2014 · 6 comments

Comments

@bitplanets
Copy link

Sometimes I don't want to create a Widget instance and I have only one class.

@bitplanets bitplanets changed the title Allow query DOM with static methods. Allow to query the DOM with static methods. Dec 15, 2014
@samccone
Copy link
Contributor

Can you provide an example with what you are looking to be able to do?

@bitplanets
Copy link
Author

        this.Widget.findAll({
          selector: "." + value
        }).then(function(value){
        })

I want to count the number of items with that class.

@bitplanets
Copy link
Author

For example

this.Widget.find({
  selector: "." + value
}).then(function(items){
    console.log(items);
    // console.log(items.length);
})

This works but I get this error

C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1643
      throw error;
            ^
TypeError: Cannot call method 'isDisplayed' of undefined
    at Widget.W.Widget.Widget.isPresent (C:\t\node_modules\pioneer\lib\support\widgets.js:205:26)
    at webdriver.promise.ControlFlow.runInNewFrame_ (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1539:20)
    at pollCondition (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1305:12)
    at C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1301:5
    at webdriver.promise.ControlFlow.runInNewFrame_ (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1539:20)
    at webdriver.promise.ControlFlow.runEventLoop_ (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1404:8)
    at wrapper [as _onTimeout] (timers.js:261:14)
    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)
==== async task ====
undefined not found
    at webdriver.promise.ControlFlow.wait (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1296:15)
    at webdriver.WebDriver.wait (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:543:21)
    at Widget.W.Widget.Widget._ensureElement (C:\t\node_modules\pioneer\lib\support\widgets.js:305:28)
    at Widget.W.Widget.Widget.find (C:\t\node_modules\pioneer\lib\support\widgets.js:159:21)
    at Function.W.Widget.Widget.find (C:\t\node_modules\pioneer\lib\support\widgets.js:45:22)
    at Object.<anonymous> (C:\t\tests\steps\missions.js:22:25)
    at C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\goog\base.js:1243:15
    at webdriver.promise.ControlFlow.runInNewFrame_ (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1539:20)
    at notify (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:362:12)
    at notifyAll (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:331:7)
    at resolve (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:309:7)
    at fulfill (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:429:5)
    at Object.webdriver.promise.asap (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:671:5)
    at webdriver.promise.ControlFlow.runInNewFrame_ (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1550:25)
    at notify (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:362:12)
    at notifyAll (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:331:7)
    at resolve (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:309:7)
    at fulfill (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:429:5)
    at C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1406:10
    at C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\goog\base.js:1243:15
    at webdriver.promise.ControlFlow.runInNewFrame_ (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1539:20)
    at notify (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:362:12)
    at notifyAll (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:331:7)
    at resolve (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:309:7)
    at fulfill (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:429:5)
    at C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\goog\base.js:1243:15
    at webdriver.promise.ControlFlow.runInNewFrame_ (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1539:20)
    at notify (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:362:12)
    at notifyAll (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:331:7)
    at resolve (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:309:7)
    at fulfill (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:429:5)
    at C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:617:49
    at C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\http\http.js:96:5
    at IncomingMessage.<anonymous> (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\http\index.js:122:7)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:943:16
    at process._tickCallback (node.js:419:13)

@samccone
Copy link
Contributor

yep makes sense, currently everything is scoped to a widget operation

@bitplanets
Copy link
Author

Also remember to make the error more descriptive, in this case you wouldn't even know where to start. Also why this error?

@samccone
Copy link
Contributor

@bitplanets open to PR's to improve the error messages

The error message is because there is no el on the static widget
https://github.com/mojotech/pioneer/blob/master/src/widgets/Widget.coffee#L136

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

No branches or pull requests

2 participants