I am trying to find text after a comment field in a form. However, there are multiple comment areas in the table. I want to be able to get the text in TD which follows TD of the second comment field. I have the following HTML:
& lt; Table & gt; & Lt; Tbody & gt; & Lt; TR & gt; ... & lt; / TR & gt; & Lt; TR & gt; ... & lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Comment: & lt; / TD & gt; & Lt; Td> This is the first comment field & lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; AnotherField: & lt; / TD & gt; & Lt; Td> The content of that area & lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Comment: & lt; / TD & gt; & Lt; Td> This is the second comment field & lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; ... & lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;
To get the text from the first comment field, I can do the following:
ret = driver.find_element_by_xpath ("// td [ However, I have to capture content from the second comment field, not on the basis of the index (text (), 'Remarks')] / following :: TD "print print.text
, 'Remarks' should be done on the basis of the incidence of incidents. I wanted to try things like this:
ret = self.driver.find_element_by_xpath ("// td [[text (), 'comment')] [1] / following:: Td")
or: / P>
rets = self.driver.find_elements_by_xpath ("// td [[text (), 'comment')]" [1] ret = elements.find_element_by_xpath ("/ following :: TD" )
Understand, these do not work, is there any way to do this?
P.S. Use an order on the lines of 'Annual Avance' comment after 'field. It should be done using xpath. The reason being, I'm trying to convert a colleagues code into Selenium from any other application that I am using Selenium-2.44.0 and Python 2.7 using xpath revolve around everything.
(// td [contains (',' Remarks']] / following-soldier :: TD [2] < / Code>
Or, you can use the find_elements_by_xpath ()
and get another item:
elements = self. Printers [1] .text
No comments:
Post a Comment