-1

HTML:

<form>
  <p>
    <label for="import-textarea">Use the "Export board" menu item in a board's menu, then copy the json from the resulting file.</label>
  </p>
  <textarea class="js-import-json" placeholder="Paste your valid JSON data here" autofocus=""/>
  <input class="primary wide" type="submit" value="Import">
</form>

I want to set the text inside the textarea, with webdriver.io and tried different selectors:

const ta = browser.$('textarea');
ta.setValue('Updated Text');

const val = imp.selectByAttribute('placeholder', 'Paste your valid JSON data here');
const text = browser.getText('.js-import-json=Paste your valid JSON data here');

But none of them seemed to work. Either i get no text at all or the selector could not be found on page.

Any ideas?

Gobliins
  • 3,382
  • 12
  • 52
  • 97
  • Have you tried `const text = ta.getValue();` ? Or `const text = browser.getValue('.js-import-json');` ? – Chris G May 18 '18 at 14:05

1 Answers1

1

You can read about setValue here http://webdriver.io/api/action/setValue.html
And about selectors here http://webdriver.io/guide/usage/selectors.html

I wrote this code only for current situation and I don't recommend writting this way, but it will work

browser.setValue('.js-import-json','Updated Text');
Leo Odishvili
  • 800
  • 5
  • 22
  • Tried this but it didn't work... gonna try it again. – Gobliins May 18 '18 at 14:22
  • Ok it seems like it's working, but when i do `browser.getText('.js-import-json');` it returns empty string, i have to access the text by `browser.getValue...`, why is that? – Gobliins May 22 '18 at 09:04