webdriverio textarea 设置文本

webdriverio textarea set Text

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>

我想在文本区域内设置文本,webdriver.io 并尝试了不同的选择器:

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');

但其中 none 似乎有效。要么我根本没有收到任何文本,要么在页面上找不到选择器。

有什么想法吗?

您可以在此处阅读有关 setValue 的信息 http://webdriver.io/api/action/setValue.html
关于这里的选择器 http://webdriver.io/guide/usage/selectors.html

我写这段代码只是针对目前的情况,我不建议这样写,但它会起作用

browser.setValue('.js-import-json','Updated Text');