To send three keys using send_keys () in selenium python webdriver

I am trying to enter a floating point number in a text box with a default value of 0.00. But it is trying to connect, not overwrite it. I tried with .clear () and then send_keys ('123.00'), but still it is added, then I tried with send_keys (Keys.CONTROL + 'a', '123.00'). It only updates 0.00.

Any help really appreciated.

Read more .. URL: http://new.ossmoketest.appspot.com userid: senthil.arumugam@mycompanyname.com - mycompanyname = orangescape (sorry to avoid spam emails) no password is needed now. click on the purchase ... in the form, please, a new product and a new price ... sample application for automation .. thanks

+6
source share
4 answers

If you don't have a custom edit field, click() should work for you:

 from selenium.webdriver import Firefox b = Firefox() b.get('http://google.com') e = b.find_element_by_id('lst-ib') e.click() # is optional, but makes sure the focus is on editbox. e.send_keys('12.34') e.get_attribute('value') # outputs: u'12.34' e.click() e.clear() e.get_attribute('value') # outputs: u'' e.send_keys('56.78') e.get_attribute('value') # outputs: u'56.78' 
+5
source

I had good results:

 from selenium.webdriver.common.keys import Keys element.send_keys(Keys.CONTROL, 'a') element.send_keys('123.00') 

If this does not work, it may have something to do with the code on the web page.

+4
source

I just found the clear () command - here here :

If this element is a text input element, this will clear the value. Does not affect other elements. Text input elements are INPUT and TEXTAREA elements.

EDIT: So your approach:

  element.clear(); element.sendKeys('123.00'); 
+3
source

I am having problems with all the examples given in the other answers.

 el.send_keys(Keys.CONTROL + 'a' + Keys.NULL, 'your string') 

He worked in all the projects that I worked on, so I included it in my own implementation of the Webdriver class with more reliable operations.

+1
source

Source: https://habr.com/ru/post/905593/


All Articles