Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get element inside current element using xpath

I have multiple questions inside which there are more than 1 options.

After selecting the required question element as question_element

I am unable to get the first text box inside this element. I used

question_element.find_elements_by_xpath("//textarea")

but it gives me list of all the elements with tag textarea in the whole webpage. I tried

question_element.find_elements_by_xpath("/textarea")
question_element.find_elements_by_xpath("./textarea")

but they didn't give any results. How do I get the first element with tag name textarea inside the question_element

like image 274
raju Avatar asked Dec 13 '12 09:12

raju


1 Answers

There are two variants that work for search within already found element (not within the whole page):

question_element.find_elements_by_xpath(".//textarea")

or

question_element.find_elements_by_xpath("textarea")
like image 164
Igor Khrol Avatar answered Oct 07 '22 10:10

Igor Khrol