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 7165119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:11:18+00:00 2026-05-28T14:11:18+00:00

I am running into an issue where I need to click on an element

  • 0

I am running into an issue where I need to click on an element twice. The first time the element is clicked it expands a tree on the page, the second time closes the tree. There is no issue when clicking the element the first time.

Here is the part of the HTML code I am working with: (The element I am clicking is the ‘a’ tag.)

<div id="uasMainForm:uasTabs:0:agencyTree-d-rt-c" name="c">
    <div title="" class="iceTreeRow" id="uasMainForm:uasTabs:0:agencyTree-d-4" name="nd">
        <a id="uasMainForm:uasTabs:0:agencyTree:4" onclick="document.forms['uasMainForm']['uasMainForm:uasMainForm:uasTabs:0:agencyTree_idtn'].value='4';iceSubmitPartial( document.forms['uasMainForm'], this,event); return false;" onblur="setFocus('');" href="javascript:;">

The weird thing is, if I run the second click immediately after running the first it closes the tree perfectly, but if I break it up with a MessageBox or some other code it throws an error when trying to perform the second click.

Here is code that works:

agency = ie.ElementOfType<Div>(Find.ByText(agencyName));
agencyTab = agency.ElementWithTag("a", Find.ByIndex(0));
agencyTab.Click();

//MessageBox.Show("Hey!");
agencyTab.Click();

Here is the code that does not work:

agency = ie.ElementOfType<Div>(Find.ByText(agencyName));
agencyTab = agency.ElementWithTag("a", Find.ByIndex(0));
agencyTab.Click();

MessageBox.Show("Hey!");
agencyTab.Click();

The above code throws the error: Could not find A element tag matching criteria: Index = 0

I have also tried Find.ById instead of ByIndex with the same result. Can anyone shed some light on what could be causing this error when breaking up the two click events, but not when the click events happen back to back?

  • 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-05-28T14:11:19+00:00Added an answer on May 28, 2026 at 2:11 pm

    I’m still not sure why this issue was occuring but I found a way around it. First I save the Id of the containing Div right before I do the first click:

    var agency = ie.ElementOfType<Div>(Find.ByText(agencyName));
    
    //Set current agency Id
    currentAgency = agency.Id;
    
    var agencyTab = agency.ElementWithTag("a", Find.ByIndex(0));
    agencyTab.Click();
    

    Then, when I want to perform the second click, I use the Id I saved earlier to find the containing Div again:

    //Close old agency's tree
    var agency2 = ie.ElementOfType<Div>(Find.ById(currentAgency));
    var agencyTab2 = agency2.ElementWithTag("a", Find.ByIndex(0));
    agencyTab2.Click();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running into an issue where I need to be able to change the
I'm running into an issue with Wicket generating markup for elements that programmatically need
I am running into an issue in Android where I think I need to
I'm running into an issue with the following. I need to clean up HTML
I'm running into an issue with a variadic function template. I need to examine
I'm running into an issue where I have a FileUpload control in an UpdatePanel.
I am running into an issue I had before; can't find my reference on
I'm running into an issue where granting EXECUTE permissions on a specific Stored Procedure
I am running into this issue of releasing an already released object but can't
I am running into an issue with the way my asynctasks are executed. Here's

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.