cancel
Showing results for 
Search instead for 
Did you mean: 

Iterating through rows and clicking on specific row element

Vars01
Occasional Contributor

Iterating through rows and clicking on specific row element

Hi Team,

 

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

 

21 REPLIES 21
Marsha_R
Community Hero

Re: Iterating through rows and clicking on specific row element

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.

https://support.smartbear.com/testcomplete/docs/testing-with/creating/recording/index.html

 

Vars01
Occasional Contributor

Re: Iterating through rows and clicking on specific row element

 
 
 
 
It is a web table on Angular application
Marsha_R
Community Hero

Re: Iterating through rows and clicking on specific row element

Here are the Angular controls that you can access in TC

https://support.smartbear.com/testcomplete/docs/general-info/supported-technologies/controls/angular...

 

Did you try recording a test?  What happened when you tried that?

Vars01
Occasional Contributor

Re: Iterating through rows and clicking on specific row element

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. 

Marsha_R
Community Hero

Re: Iterating through rows and clicking on specific row element

I suggest figuring out how to process one row first and then building the loop around that code.

Vars01
Occasional Contributor

Re: Iterating through rows and clicking on specific row element

@Marsha_R 

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");

Marsha_R
Community Hero

Re: Iterating through rows and clicking on specific row element

@AlexKaras Can you help?  I don't know xpath in this context.

AlexKaras
Community Hero

Re: Iterating through rows and clicking on specific row element

@Vars01 :

 

Hi,

 

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.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
Vars01
Occasional Contributor

Re: Iterating through rows and clicking on specific row element

@Marsha_R @AlexKaras 

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.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors