A
A
asinco2021-12-09 10:12:51
Python
asinco, 2021-12-09 10:12:51

How to insert text in Selenium?

Python selenium.

I used to write on old versions, there was a good search for elements. There you could easily insert data into the input field using the send_keys() method.

Now, in the new version, an error occurs (purely a warning, the code continues to work), that you need to use this search otherwise. This code will find me the login input field. The clear() method has remained and seems to be working, but how to transfer something now? I didn’t see anything in the documentation, but I don’t want to install the old version

driver.find_elements(By.NAME, "username")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Crd5, 2021-12-09
@Crd5

driver.find_elements("xpath" ,  "Путь к xpath").send_keys("Текст")

Instead of "xpath" you can use other methods ("css selector" for example) and insert the path to xpath (css selector)
All methods: `css selector`, `link text`, `partial link text`, `tag name`, ` xpath`
If the sent text is in Russian, then the beginning of the code should be # -*- coding: utf-8 -*-

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question