0

I have been trying to send a URL link to a text area. I am using python3 and Chrome Version 109.0.5414.119. It worked fine on my local OSX machine but when I tried to automate it on a Linux Machine. It started behaving weirdly. So I have this feeling that It can be a Chrome Driver-related issue.

When I send a URL like this:

l.send_keys("https://google.com")

But becomes:

/google.comhttps:

Then I tried to debug this behavior by sending the following:

>>> l.send_keys("/") # /|
>>> l.send_keys("/") # |/

So the position of the cursor is going ahead of the line for the second /. I was not expecting this. I wonder if you can shed light on how to solve this?

sadaf2605
  • 7,332
  • 8
  • 60
  • 103

1 Answers1

0

Possibly you are trying to invoke send_keys() too early within the <input> field even before the element have rendered properly.


Solution

Ideally to send a character sequence to the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "element_css_locator"))).send_keys("https://google.com")

Note: You have to add the following imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352