Finding web table (sub-)components
Dear all,
I have some troubles finding tables (components) on the a web page, when using the Tree model and Javascript. Basically, I'm trying to get the (1) column headers and the (2) body of the table containing the data (these two things are a sort of sub-tables within the big (composite) table, see the first attached picture).
I've tried using the Find method, to get to the subcomponents searching after their class, their tagName, or some qa atributes, but I didn't have any success (please see the code below). I don't want to get stuck having the full path of the tables, although this works (i.e. I can find the table subcomponents if I provide their full path - but this makes code hardly readable and the path will not work for other pages). If I would search after ObjectType=Table, I don't know how to get the other sub-component (I think for every search the same subcomponent will be found by the Find method).
Any help/suggestions are welcomed on how to deal with class/tagName/tbody/thead.
Thank you!
R
function DetectTableComponents() { var page = Sys.Browser("chrome").Page("*"); page.Wait(); Sys.HighlightObject(page); // finding the big (composite) table. This is ok var parent = page.Find("data-qa", "qa-table", 20); var obj; /*it works*/ obj = Sys.Browser("chrome").Page("*").Panel("root").Panel(0).Panel(0).Panel(1).Panel(0).Panel(1).Panel(1).Panel(0).Panel(0).Panel(1).Panel(0).Panel(0).Panel(0).Table(0); /*DOESN'T WORK*/// obj = parent.Find("Class", "thead", 20); /*DOESN'T WORK*/// obj = parent.Find("tagName", "thead", 20); Sys.HighlightObject(obj); Log.Message("1. These are the column headers", obj.FullName, pmNormal, "Default attributes", obj); /*it works*/ obj = Sys.Browser("chrome").Page("*").Panel("root").Panel(0).Panel(0).Panel(1).Panel(0).Panel(1).Panel(1).Panel(0).Panel(0).Panel(1).Panel(0).Panel(0).Panel(1).Table(0); /*DOESN'T WORK*/// obj = parent.Find("class", "tbody", 20); /*DOESN'T WORK*/// obj = parent.Find("tagName", "tbody", 20); /*DOESN'T WORK*/// obj = parent.Find("class", "table-enhanced__body", 20); /*DOESN'T WORK*/// obj = parent.Find("data-qa", "qa-table-body", 20); Sys.HighlightObject(obj); Log.Message("2. This is the data part", obj.FullName, pmNormal, "Default attributes", obj); }