0

I'm working with a website where send_keys sometimes works and sometimes doesn't (I have no idea why). Sometimes it sends keys then I try a few hours later and it doesn't work anymore. I was wondering if anyone knew a way to send text/numbers into a input element WITHOUT using send_keys.

For example, would it be possible to input text into the following element without using send_keys:

<input _ngcontent-coh-c546="" type="text" name="tag" maxlength="25" placeholder="Tags" class="ng-dirty ng-valid ng-touched">

Any help would be greatly appreciated. Thank you.

8
  • Please add more details to your question such as your python script. Commented May 6, 2022 at 2:22
  • Have you ever tried pyautogui pypi.org/project/PyAutoGUI Commented May 6, 2022 at 2:25
  • 1
    You probably can't input anything without using send_keys Commented May 6, 2022 at 2:25
  • 1
    I found an article which uses JavaScript for the purpose. Click here. Commented May 6, 2022 at 2:27
  • 1
    I can be written in Python using driver.execute_script(). Commented May 6, 2022 at 2:44

1 Answer 1

1

This should work effectively and faster compared to send_key

from selenium import webdriver

driver = webdriver.Chrome('chromedriver')
driver.get("http://www.google.com");
driver.execute_script("document.getElementsByName('q')[0].value='What ever you want to be typed here'")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.