Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

how to get ELEMENT value in Standalone Mode #12

Open
christian-bromann opened this issue Jan 25, 2019 · 2 comments
Open

how to get ELEMENT value in Standalone Mode #12

christian-bromann opened this issue Jan 25, 2019 · 2 comments
Labels
Bug🐛 help wanted Extra attention is needed v4

Comments

@christian-bromann
Copy link
Contributor

From @jiangyd on October 29, 2018 7:25

> var webdriverio = require('webdriverio');
undefined
> var options = { desiredCapabilities: { browserName: 'chrome' } };
undefined
> var client = webdriverio.remote(options);
undefined
> client.init().url("https://csos.cloudcare.cn")
{ state: 'pending' }
> var eleobject=client.element('/html/body/div[2]/header/div[2]/a[2]/input')
undefined
> console.log(eleobject)
{ state: 'fulfilled',
  value:
   { sessionId: '95a30dc18d91b93def35e58cc5cfd405',
     status: 0,
     value:
      { ELEMENT: '0.8181596695218141-1',
        'element-6066-11e4-a52e-4f735466cecf': '0.8181596695218141-1' },
     selector: '/html/body/div[2]/header/div[2]/a[2]/input' } }
undefined
> console.log(eleobject.value.value.ELEMENT)
TypeError: Cannot read property 'value' of undefined
    at repl:1:29
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:240:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:442:10)
    at emitOne (events.js:121:20)
    at REPLServer.emit (events.js:211:7)
    at REPLServer.Interface._onLine (readline.js:282:10)
    at REPLServer.Interface._line (readline.js:631:8)
> client.elementIdRect(client.element('/html/body/div[2]/header/div[2]/a[2]/input').value.ELEMENT)
TypeError: Cannot read property 'ELEMENT' of undefined
    at repl:1:88
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:240:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:442:10)
    at emitOne (events.js:121:20)
    at REPLServer.emit (events.js:211:7)
    at REPLServer.Interface._onLine (readline.js:282:10)
    at REPLServer.Interface._line (readline.js:631:8)

Copied from original issue: webdriverio/webdriverio#3027

@christian-bromann christian-bromann added Bug🐛 help wanted Extra attention is needed v4 labels Jan 25, 2019
@christian-bromann
Copy link
Contributor Author

From @erwinheitzman on October 30, 2018 17:42

This is not an issue but a question, please use our gitter channel for this.

To answer the question though, you use it like this:

webdriverio
  .remote(options)
  .init()
  .url('some-page')
  .element('#some-input')
  .setValue('some value')
  .getValue('#some-input').then(value => {
    console.log('Value was: ', value); // logs "Value was: some value"
  })
  .end()
  .catch(function(err) {
      console.log(err);
  });

@christian-bromann
Copy link
Contributor Author

This can be related to the repl interprets the return value. Let's reopen.

@jiangyd note that we are working hard on the new WebdriverIO version so we can't look into fixing a bug of a version that will be deprecated soon. We are happy to accept pull requests that fix the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug🐛 help wanted Extra attention is needed v4
Projects
None yet
Development

No branches or pull requests

1 participant