我想选择文本框中的所有文本以清除文本框。我使用Ctrl + A键做到这一点使用下面的Python 2.7硒RC独立2.20.0.jar服务器上的代码在Windows 7上的Firefox:选择文本框中的所有文本Selenium RC使用Ctrl + A
from selenium import selenium
s = selenium('remote-machine-ip', 4444, '*chrome', 'http://my-website-with-textbox')
locator = 'mylocator-of-textbox'
s.open()
s.type(locator, 'mytext')
s.focus(locator)
s.control_key_down()
s.key_down(locator, "A")
s.key_press(locator, "A")
s.key_up(locator, "A")
s.control_key_up()
# Nothing happens here... I cannot see the text getting selected...
# Nothing gets cleared here except the last char
s.key_down(locator, chr(8)) # Pressing backspace
s.key_press(locator, chr(8))
s.key_up(locator, chr(8))
任何帮助吗? 谢谢, 阿米特
我不使用WebDriver,因为我使用Selenium RC ...任何想法如何在Selenium RC中执行相同的操作...我现在不想移动到WebDriver ... – abarik 2012-08-06 21:48:41
如果.clear不是出现在RC(我认为是),那么'.type(“”)'? – starenka 2012-08-06 21:53:08
我尝试过.type(“A”)来代替.key_down/press/up()....但是我得到以下异常:在调用controlKeyDown()或altKeyDown()或metaKeyDown()之后立即支持 类型) – abarik 2012-08-06 21:54:37