Chrome Web Key Submission Keys Don't Send '3'

For some reason, I cannot write the character "3" in the input element of the page.

This code:

    chrome_options = Options()
    chrome_options.add_argument('--dns-prefetch-disable')
    chrome_options.add_argument('--no-proxy-server')
    chromeDriverPath = self.getChromeDriverPath()
    os.environ["webdriver.chrome.driver"] = chromeDriverPath
    self.driver = webdriver.Chrome(chromeDriverPath, chrome_options=chrome_options)

    self.driver.get(self.loginUrl)
    login = self.driver.find_element_by_id('login_credit')
    login.send_keys("12345")

leads to "1245", which is written to the input of the input ... Can someone help please? I am using python 2.7, last chrome and last chrome recorder

EDIT:

login.send_keys("3")

login.send_keys("\3")

also do not work.

login.send_keys("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()")

- the line is missing only "3" ...

what worked

login.send_keys(Keys.NUMPAD3)

as Andersson suggested below, but this is not a solution.

I tried this in the google search box and I experienced the same behavior.

+4
source share
3 answers

Updating the latest version of chrome driver resolved this issue.

+5
source

send_keys("12345") :

  • Keys.NUMPAD3:

    login.send_keys(Keys.NUMPAD3)
    
  • JavascriptExecutor getElementById:

    self.driver.execute_script("document.getElementById('login_credit').value='12345'")
    
  • JavascriptExecutor getElementsById:

    self.driver.execute_script("document.getElementsById('login_credit')[0].value='12345'")
    
+1

Strange problem, try passing a string variable to send_keysand try, maybe it works for you

my_str = "12345"
login = self.driver.find_element_by_id('login_credit')
login.send_keys(my_str)
0
source

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


All Articles