Select all the text in the Selenium RC text box using Ctrl + A

I am trying to select all the text in a text box to clear the text box. I use Ctrl + A to do this, using the following Python 2.7 code on a standalone Selenium RC 2.20.0.jar Server on Windows 7 firefox:

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)) 

Any help? Thanks, Amit

+4
source share
3 answers

I am using clear () in WebDriver without any problems ...

 el = self.selenium.find_element_by_name(name) el.clear() 
+5
source

In Selenium RC, simply use the following to clear the text box

selenium.type ("someLocator", "");

0
source

Try to use the first

 element.click() 

then use the item

 element.clear() 

This may solve your problem as it really solved my problem.

0
source

All Articles