vthomeschoolmom
6 years agoSuper Contributor
Really TR not supported in Firefox and Chrome? Do I understand this correctly
Consider this code:
// Select desired cell. If not already selected, click it. (If // it is already selected do not click as clicking will de-select.) // Row objects are not present for FF and Chrome? function SelectCell(table, rowIndex, colIndex) { Log.Message(Options.Web.TreeModel); var row = table.Row(rowIndex); if (!IsRowSelected(row)) { table.Cell(rowIndex, colIndex).scrollIntoView(); aqUtils.Delay(ProjectSuite.Variables.TinyWaitTimeout); /// inconsistent error on click table.Cell(rowIndex, colIndex).Click(); } }
which calls IsRowSelected
function IsRowSelected(row) { var rowClassName = row.className; if (rowClassName.includes("row-selected")) { return true; } return false; }
Which determines whether or not the row is selected before click. Very handy.
But not supported in Chrome and Firefox? Is there no way to get the class of a TR in Chrome and Firefox? Or really anything off the TR tag?
Hi vthomeschoolmom,
I see that you are working with the Support team on this question. Let me post their reply here:
Hi Stephanie,
Thank you for creating this case. In TestComplete, you can access the HTML DOM document object of web pages, by using the contentDocument property of the page. You can also use contentDocument.Script property of the page to execute scrips on web pages.
To obtain the class of a TR tag in Chrome/Firefox, you can utilize the JavaScript method(s): querySelector or getElementsByClassName to obtain the TR tag object and then locate the className property afterwards. See below for a sample TestComplete script:
function queryTR() {
var page = Sys.Browser("chrome").Page("*");
var className = page.contentDocument.Script.eval('document.getElementsByClassName("parent")[0].children[0].children[1].className');
Log.Message(className);
}
Refer to the following documentation regarding running JavaScript on web pages using TestComplete:
Executing JavaScript on Web Pages: https://support.smartbear.com/testcomplete/docs/app-testing/web/general/common-tasks/javascript.html
Accessing DOM document Object: https://support.smartbear.com/testcomplete/docs/app-testing/web/general/common-tasks/document-object.html
Let me know if you have any questions.