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

  • Home
  • SEARCH
  • 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 7249071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:14:29+00:00 2026-05-28T22:14:29+00:00

I have two elements on my page (two ‘cancel’ elements). <div unselectable=on class=x-grid-cell-inner x-unselectable

  • 0

I have two elements on my page (two ‘cancel’ elements).

<div unselectable="on" class="x-grid-cell-inner x-unselectable" style="text-align: left; " id="ext-gen1179">
Cancel
</div>

<div unselectable="on" class="x-grid-cell-inner x-unselectable" style="text-align: left; " id="ext-gen2951">
Cancel
</div>

How do I click on the second element? Obviously, I can’t us id because it is randomly generated on each visit. What can I use?

  • 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-28T22:14:32+00:00Added an answer on May 28, 2026 at 10:14 pm

    1. Use FindElements method, which finds all IWebElements within the current context using the given mechanism. (In this case, you always need to know the index of the element you are looking for.)

    IWebDriver driver = new FirefoxDriver();
    IList<IWebElement> cancelDivs = driver.FindElements(By.XPath("//div[text()='Cancel']"));
    cancelDivs[1].click(); //zero-base index
    

    2. If those cancel buttons are in different sections, which can be identified by non-ExtJS id attributes.

    <div id='header'>
        <div unselectable="on" class="x-grid-cell-inner x-unselectable" style="text-align: left; " id="ext-gen1179">Cancel</div>
    </div>
    <div id='footer'>
        <div unselectable="on" class="x-grid-cell-inner x-unselectable" style="text-align: left; " id="ext-gen2951">Cancel</div>
    </div>
    

    IWebElement secondCancelDiv = driver.FindElement(By.XPath("//div[@id='footer']//div[text()='Cancel']"));
    secondCancelDiv.Click();
    

    3. If those cancel buttons are in different sections, which can be identified by different ExtJS class attributes. (use the meaningful ones)

    <div id='ext-gen1060' class='x-grid3-body'>
        <div unselectable="on" class="x-grid-cell-inner x-unselectable" style="text-align: left; " id="ext-gen1179">Cancel</div>
    </div>
    <div id='ext-gen2555' class='x-toolbar-right-row'>
        <div unselectable="on" class="x-grid-cell-inner x-unselectable" style="text-align: left; " id="ext-gen2951">Cancel</div>
    </div>
    

    IWebElement secondCancelDiv = driver.FindElement(By.XPath("//div[@class='x-toolbar-right-row']//div[text()='Cancel']"));
    secondCancelDiv.Click();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two div elements on a page. How can I make one div
I have these two elements in my page: <input type='button' value=undo style=display:none onClick =
We have a page that ordinarily has two elements arranged side-by-side. Despite exploring a
I have two div elements that are twins (i.e. their dimensions and contents are
I have two elements on the same page that are using the same stylesheet:
I have the following two td elements <TD ALIGN=LEFT VALIGN=top WIDTH=150 STYLE=font-size: 11px; font-family:
I have two form elements on my page that act as a smooth login
I have two <span> elements: <span style=margin-right:auto;>©2012 XYZ Corp. All Rights Reserved.</span> <span style=margin-left:auto;>Built
I have two elements on a page. One being the main content container and
Ok. So I have two elements on a page which are not located in

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.