简体   繁体   中英

Protractor E2E Test - How can I get a Table Heading by its repeater?

Looking at this topic , I can get the information for a table heading by it's class/tags. However, for the table I have I would like to get mine using the repeater.

I know I can get the rows using element.all(by.repeater('row in myRows')) but that only seems to include the tr rows themselves, and not the heading ( th ) row.

How can I use by.repeater to get the row of headings?

One option would be to get one repeater row and use ancestor to get the table parent element. Then, you can get to the th header elements from there:

var rows = element.all(by.repeater('row in myRows'));
var table = rows.first().all(by.xpath("ancestor::table")).last();
var headers = table.all(by.tagName("th"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM