Access TextArea using selenium


I have a website where I would like to extract some specific information. This website has a text area placeholder where to add some text.
I am trying to use selenium as follows:

from selenium import webdriver

url = ''

driver = webdriver.Chrome('my path/chromedriver')

The path where I can get information on Text Area should be

  <div class="index-wrap">==$0
  <div class="left-s-wrap">
   <div id="table">
    <div class="table">
     <div class="container">
      <div class="table__input"> ==$0
       <div class="row tab">
        <div class="table__input-wrap table__input-wrap_multiline">
         <textarea placeholder="" wrap="hard" spellcheck="false"></textarea>
          <button class="button button_accent-green">Add URLs</button>

Specifically the part which is going to be edited by entering urls is

         <textarea placeholder="" wrap="hard" spellcheck="false"></textarea>

I guess that I need to use find_element_by_xpath and click, similarly to this:

        textarea = site.find_element_by_xpath('//textarea')

But I am not familiar with process and I am a beginner in using these methods to access textarea.
Any help on this will be extremely helpful!

Update question:
Although I’ve followed the suggested method below, I cannot submit the query:

from selenium import webdriver
import time

chrome_options = webdriver.ChromeOptions()

driver = webdriver.Chrome('my path/chromedriver',chrome_options=chrome_options)
textarea = driver.find_element_by_xpath('//textarea')

How can I click on submit to gather information from the website?


You need to use the send_keys method to send a text to the textarea.

textarea = site.find_element_by_xpath('//textarea')

And you can use these codes to extract the value of the textarea

textarea = site.find_element_by_xpath('//textarea').get_attribute("value")


textarea = site.find_element_by_xpath('//textarea').text

UPDATE: to click on the "Add URLs" button, you can use this xpath:( With assuming that there are no other buttons with the same class before "Add URLs" button)

//button[@class='button button_accent-green']

if there are other buttons with the same class before the "Add URLs" button, you can use this xpath.

//button[text()='Add URLs']

So, the clicking code will be:

# with using the class name
button = site.find_element_by_xpath("//button[@class='button button_accent-green']")
# with using the text of the button
button = site.find_element_by_xpath("//button[text()='Add URLs']")

Answered By – Y sharifpour

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published