java - Getting each <th> on the Table -


I have a table that grows like this:

   

I & lt; Th & gt; How can I take value from ?
My idea is, this is: Create one for each & lt; Th & gt; will run around the table being received.
Is this possible? Someone has any idea how I can use Selenium-WebDriver (Java)

My solution for this ArrayList & lt ; String & gt; Table List = New Arrestist & lt; String & gt; (); (Int i = 1; i & lt; = NUMBEROFROWSINYOURTABLE; i ++) {tableList.add (driver.findElement (by.expath ("// div [@ id = 'heatmap-container'] / table / TDI / Tr ["+ I +"] / th ") getAttribute (" title ")). }

But you can also follow the examples of @indiprapper answers.

The following example is in Python, but it is up to you to do this how to do it. Basically, get table elements based on anything you have available. Then, on that element, search the "Call" Elements for all the names in the "find" call name. This will give you a list of all the th elements within that specific table. Then, just repeat on the elements and print your values.

  table_element = driver.find_element_by_id ("tableid") th_elements = table_element.find_elements_by_tag_name ("th") for elements in th_elements: Print Element.text  

In Java, it will look something like this

  WebElement tableElement = driver.findElement (By.id ("tableid")); & Lt; WebElement & gt; ThElements = tableElement.findElements (by.tagName ("th")); For (int i = 0; i & lt; thElements.size (); i ++) {System.out.println (thElements.get (i) .getText ()); }  

Comments