webdriverio textarea设置文本

时间:2018-05-18 13:48:46

标签: javascript html webdriver webdriver-io

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>

我想在textarea中设置文本,使用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');

但他们似乎都没有工作。要么我根本没有文字,要么在页面上找不到选择器。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

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

我仅针对当前情况编写此代码,我不建议以这种方式编写,但它会起作用

browser.setValue('.js-import-json','Updated Text');
相关问题