在量角器的文本框中选择或键入文本的最简单方法? [英] Easiest way to select or type over text in a text box in protractor?

查看:38
本文介绍了在量角器的文本框中选择或键入文本的最简单方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在量角器测试中,我有一个 <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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆