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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:55:49+00:00 2026-05-27T21:55:49+00:00

I have this HTMLcode: <div class=A> <div class=B> Text1 </div> </div> <div class=A> <div

  • 0

I have this HTMLcode:

<div class="A">
  <div class="B">
    Text1
  </div>
</div>
<div class="A">
  <div class="B">
    Text2
  </div>
</div>

So i need to find index of div class=’A’ where i find some text. I use Watir Webdriver and now i have this code:

if @ff.div(:class=>'A').div(:text=>'Text1')
  then ind=@ff.div(:class=>'A').index
end

but of course this doesn’t work saying ‘undefined local variable or method `index”.

  • 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-27T21:55:49+00:00Added an answer on May 27, 2026 at 9:55 pm

    There’s no way to get the index using the webdriver since they are relative to the collection of matched elements. What you can try to do is collect the elemetns text as Array and then get the index of the target text.

    @@ff.divs(:class, 'A').collect(&:text).index('Text1')
    

    Note that this will only work for simple scenarios (like your example). If you need to attack a more complex case update your example to match the real scenario.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have html code block like this <div id=some-div> <a href=# class=link-click>some link text</a>
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div>
I have html code that looks roughly like this: <div id=id1> <div id=id2> <p>some
i have this html code <div class=container id=container> <div class=post><h1>first title</h1>description here</div> <div class=post><h1>second
can anyone explain me what happen here?? i have this html code: <div class=calculadora>
For instance I have this html code <div class=messageContainer> <div class=message> </div> </div> ---Here
I have this html code and want to use the text in the divs
I have a HTML code like this: <div class=links nopreview><span><a class=csiAction href=/WebAccess/home.html#URL=centric://REFLECTION/INSTANCE/_CS_Data/null>Home</a></span>&nbsp;•&nbsp;<span><span><a class=csiAction href=/WebAccess/home.html#URL=centric://SITEADMIN/_CS_Site>Setup</a></span>&nbsp;•&nbsp;</span><span><a
I have the following code in a view: <div class=wrap_select> @Html.DropDownList(dateRange, new SelectList(Model.DateRange, Value,Text),
I have the following HTML code <div class=text>bla bla bla bla</div> <div class=button>Show</div> And

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.