用硒清除 textarea 中的文本 [英] Clear text from textarea with selenium

查看:23
本文介绍了用硒清除 textarea 中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进行了一些测试,检查当某些字段中的文本无效时是否显示正确的错误消息.一种有效性检查是某个 textarea 元素不为空.

I've got some tests where I'm checking that the proper error message appears when text in certain fields are invalid. One check for validity is that a certain textarea element is not empty.

如果这个 textarea 中已经有文本,我如何告诉 selenium 清除该字段?

If this textarea already has text in it, how can I tell selenium to clear the field?

类似:

driver.get_element_by_id('foo').clear_field()

推荐答案

driver.find_element_by_id('foo').clear()

这篇关于用硒清除 textarea 中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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