Iterating through rows and clicking on specific row element
I am a beginner in TestComplete and coding too. Was creating one basic script and didnt know which method to use:
I have data available in rows (example : 10 rows) and I have to iterate through these rows one by one and verify the row details and navigate to desired row to click on the element.
I am unable to understand which method to use FindAll or Find Elements and what to define inside the method. can anyone help me on this.
xpath - //table/tbody/tr - common for all rows
A little more information would be helpful. What is your application written in? This will help determine what kind of table you have.
A quick way to get some example code is to use the Record function and go through your steps manually. You can get a keyword test out of that and use Convert to Script to see the script equivalent.
Here are the Angular controls that you can access in TC
Did you try recording a test? What happened when you tried that?
Thanks. I tried with recording. It gets recorded but the elements changes its location. So I wanted to iterate through all rows and whichever matches exactly I want to click.
I tried selecting but I am not able to click on the element or capture the text present on it. Please have a look at the script below:
ItemCount = Aliases.browser.page.FindElements("xpath");
for(var i = 1; i <= ItemCount.length ; i++)
//I want to capture the Text for the below and click on the link how should I do that. I am not able to get any function like getText/click
var Name = page.FindElement("xpath[" + i + "]/td");
Can you provide a screenshot of the html markup for the table and several its rows? (Or copy-paste it from browser's Developer tools)
Complimentary screenshot from the Object Browser in TestComplete that corresponds to the same table might help as well.
/Alex [Community Champion]
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
Thanks for the reply. It worked for me I am able to select the desired row and click on it. I have used do while loop so if the condition is false then also the element should be verified once.
I have one additional doubt here - if we have button which is enabled in one screen but disabled in another screen how should we verify that. I am putting a condition in while loop as mentioned "while(x.Enabled == true)". but my loop is not stopping even though the button has become false. Is there any solution to check this.