Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8835937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:22:36+00:00 2026-06-14T09:22:36+00:00

EDIT: I have updated my question and I know that I can increase the

  • 0

EDIT: I have updated my question and I know that I can increase the loop instead of 4 to 12 but the reason I have separate three for-loop is due to that; after iterating first loop i have to click carousel in order to go to the next next iteration as you can see my updated code. – sorry somehow i missed the code while copy/pasting.

I want to iterate through the rows, the total rows I have is 3 and every row has 4 columns, for an example:

row 1 has 4 columns
row 2 has 4 columns
row 3 has 4 columns

I have created 3 separate for-loop and my code works but I believe there is room to improve my code, can it have in one loop instead of three?

here is the code:

//first row

for (int j = 0; j < 4; j++) 
{  
   string _image = String.Format("id('gen{0}')/a[{1}]/img", j, "1");                 
   string _text = String.Format("id('gen{0}')/a[{1}]", j, "2");
   ...........
   WaitForElement(By.XPath(_text)).Click();
}

_carouselDot = String.Format("id('HomePage1_Carousel1')/div/ul/li[{0}]/a", 2);
WaitForElement(By.XPath(_carouselDot)).Click();

//second row
for (int j = 4; j < 8; j++) 
{  
   string _image = String.Format("id('gen{0}')/a[{1}]/img", j, "1");                 
   string _text = String.Format("id('gen{0}')/a[{1}]", j, "2");
   ...........
   WaitForElement(By.XPath(_text)).Click();
}

_carouselDot = String.Format("id('HomePage1_Carousel1')/div/ul/li[{0}]/a", 3);
WaitForElement(By.XPath(_carouselDot)).Click();

//third row
for (int j = 8; j < 12; j++) 
{  
   string _image = String.Format("id('gen{0}')/a[{1}]/img", j, "1");                 
   string _text = String.Format("id('gen{0}')/a[{1}]", j, "2");
   ...........
   WaitForElement(By.XPath(_text)).Click();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:22:38+00:00Added an answer on June 14, 2026 at 9:22 am

    What’s wrong with this –

    for (int j = 0; j < 12; j++) 
    {  
       string _image = String.Format("id('gen{0}')/a[{1}]/img", j, "1");                 
       string _text = String.Format("id('gen{0}')/a[{1}]", j, "2");
       ...........
       WaitForElement(By.XPath(_text)).Click();
    
       if(i % 4 == 3 && i != 11)
       {
          _carouselDot = String.Format("id('HomePage1_Carousel1')/div/ul/li[{0}]/a",
                                                                     (i/4 + 2));
           WaitForElement(By.XPath(_carouselDot)).Click();
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit (updated question) I have a simple C program: // it is not important
Short Question I have a loop that runs 180,000 times. At the end of
EDIT: I have fixed all but two warnings now, so thank you all for
EDIT: I have changed the question as it was too localized and gained negative
Edit 1 Updated to make the enum not an argument to the method... Question
I know this is a frequently asked question, however none of the solutions that
This is a simple question, and a seemingly simple task but I can't find
I hope someone here can help me. I know that in IE 9, there
I know I should show what I've tried so that I can get better
(Sorry if it's a trivial question.) I have documents that looks like this (Python

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.