在量角器的文本框中选择或键入文本的最简单方法是什么? [英] Easiest way to select or type over text in a text box in protractor?
本文介绍了在量角器的文本框中选择或键入文本的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在量角器测试中,我有一个 <input type="text"/>
预填充了一个值,我想删除该值并输入一个新的一.理想情况下,我可以说类似
In a protractor test I have an <input type="text"/>
that is pre-filled with a value, and I'd like to erase that value and type a new one. Ideally I'd be able to just say something like
// Some way to select all the text in the text box so `
// sendKeys` will type over it.
element(by.css("input.myInput")).selectAll();
element(by.css("input.myInput")).sendKeys("my new value");
但是 selectAll
不存在,我在 API 文档中找不到任何有用的东西.
But selectAll
doesn't exist and I can't find anything helpful in the API docs.
有什么想法吗?
推荐答案
我在我的一个测试中使用 clear
来做这件事,就像一个魅力;)
I use clear
to do this in one of my tests, works like a charm ;)
element(by.css("input.myInput")).clear();
这篇关于在量角器的文本框中选择或键入文本的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文