sebv/node-wd-sync

@elementsByXXX do not return elements

Closed this issue ยท 5 comments

All of "@elementsByXXX" methods just return something like this (based on the number of matches). I've no idea how to fix this ๐Ÿ˜Ÿ

[ { value: '0',
    browser: 
     { sessionID: '61988c81-afcb-405a-8671-4a6f68025eda',
       username: undefined,
       accessKey: undefined,
       basePath: '/wd/hub',
       https: false,
       options: [Object],
       defaultCapabilities: [Object] } },
  { value: '1',
    browser: 
     { sessionID: '61988c81-afcb-405a-8671-4a6f68025eda',
       username: undefined,
       accessKey: undefined,
       basePath: '/wd/hub',
       https: false,
       options: [Object],
       defaultCapabilities: [Object] } },
  { value: '2',
    browser: 
     { sessionID: '61988c81-afcb-405a-8671-4a6f68025eda',
       username: undefined,


sebv commented

You can do it like this.
var queryField = browser.elementByName('q'); queryField.type(queryField);
Or pass it as a parameter like in the example.

I think what he is getting at is that when you make a call to return a single element you get a nicely wrapped object with methods like click. However when you get back multiple elements all you have is a value property. What can be done with this? How can we get back a list of wrapped objects like the call for a single element?

Yep,

That was what I was trying to say. I spent some time with the code, but couldnt come up with anything.

On 24.4.2013, at 20.22, Alan Lindsay notifications@github.com wrote:

I think what he is getting at is that when you make a call to return a single element you get a nicely wrapped object with methods like click. However when you get back multiple elements all you have is a value property. What can be done with this? How can we get back a list of wrapped objects like the call for a single element?

โ€”
Reply to this email directly or view it on GitHub.

sebv commented

Looks like It is already wrapped.

Below is an example:

wdSync = require 'wd-sync' 

{browser, sync} = wdSync.remote()

sync ->        
  console.log "server status:", @status()
  @init browserName:'firefox'

  @get "http://google.com"
  console.log @title()          

  els = @elementsByTagName 'div'

  # console.log els

  for el in els
    el.click (err) ->
      console.log("clicked", err);

  @quit()  

Let me know if you still have issue, and provide a code sample and I'll reopen.

sebv commented

Should be fixed in 1.2.0. Sorry it took me some time to understand what the issue was . Next time it would be best to provide some code samples.