Sachin Sardiwal
Sachin Sardiwal

Reputation: 5

Not able to insert text in textbox using Selenium (using firefox)

I'm trying to insert text into a text box. When I inspect the textbox I found out that their are no identifiers for the text box so I used the xpath.

On inspecting the textbox

textbox = driver.find_elements_by_xpath("/html/body/main/article/div/div/div[3]/div/div[1]/div/div/form/div[1]/div/div/div/div[1]/textarea")
textbox.click()
textbox.send_keys("convert")

But it throws an error

"AttributeError: 'list' object has no attribute 'click'".

I tried to find out where the text gets written and it is written in Code-line class. Code gets written here

I don't understand what's actually going on here because I have not seen any textbox which don't have any identifier.

How can I identify the textbox and insert text into it?

Upvotes: 0

Views: 258

Answers (1)

NarendraR
NarendraR

Reputation: 7708

You should use driver.find_element_by_xpath instead of driver.find_elements_by_xpath

driver.find_element_by_xpath returns single webelement so you can perform the action like click or sendkeys

driver.find_elements_by_xpath returns list of webelement So you need to iterate the list to extract the webelement one by one

Upvotes: 1

Related Questions