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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:39:55+00:00 2026-06-02T01:39:55+00:00

I am using watir-webdriver (0.5.3) in a Cucumber (1.1.9) test. I am attempting to

  • 0

I am using watir-webdriver (0.5.3) in a Cucumber (1.1.9) test. I am attempting to verify the text value of an <acronym> tag. The code is legacy, and there are plans to change it to a <div> or <span> tag, but in the mean time I have to deal with it. I first attempted:

@browser.acronym(:id => /expense_code(.*)/).text

I received the following error:

NoMethodError: undefined method `acronym' for #<Watir::Browser:0x33e9940>

I poked around in the Watir code to see how tag objects were being created, and found that they seem to be dynamically created based on the HTML5 spec, but then I also found a comment in element.rb stating that they are no longer being created from the spec. At any rate, I couldn’t see an easy way to inherit a <span> object and call it an <acronym> object. So, I looked into alternatives, and found the element object.

@browser.element(:id => /expense_code(.*)/).text

This code works, but it takes about a minute to traverse my page. I’m stuck with the regex for now, as the tag id is actually dynamically generated and I don’t currently have a way to figure out those values. This is what the tag actually looks like:

<acronym class="editable select fillwith:exp_codes default:E100"
title="Expense Code: Expenses" id="expense_code114_582_10777">
E100    </acronym>

I would appreciate any thoughts on how I can improve the performance of my test.

  • 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-02T01:39:57+00:00Added an answer on June 2, 2026 at 1:39 am

    I’m not sure what the proper etiquette is here, but this is the answer I came up with using Chuck’s reply and feedback from jarib in the #watir IRC chat. With all my examples, expense_code = 'E100'.

    @browser.element(:tag_name => "acronym", 
                        :class => "default:#{expense_code}").text
    

    The above code works at a very reasonable speed and doesn’t require an xpath. It is a shortening of the following code:

    @browser.element(:tag_name => "acronym", 
         :class => "editable select fillwith:exp_codes default:#{expense_code}").text
    

    I learned that I didn’t need to pass the whole string. Anything in a class delimited by a space is dealt with gracefully by watir. I adapted that code from this xpath:

    @browser.element(:xpath => "//acronym[contains(@class,
        \'editable select fillwith:exp_codes default:#{expense_code}\')]").text
    

    The gotcha in that code above was needing to escape out the ' around the class values so that it would evaluate correctly.

    Just searching for the class (code below) did not work. I have no idea why. I did notice that it pounded the database with requests. Whatever it was doing, the page didn’t like it. Though the reason it was trying multiple times is I slipped a wait_until_present in there.

    @browser.element(:class, "editable select fillwith:exp_codes
        default:#{expense_code}").text
    

    Thanks for the help. 🙂

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

Sidebar

Related Questions

I'm using cucumber-watir-webdriver with for automation purposes. I have the following directory structure: |features
I'm using Watir-webdriver and I was wondering if there was a good way to
I'm attempting to launch chrome using watir-webdriver but with a specific extension loaded. I
I'm checking results of values to verify that they are correct. Using watir-webdriver. In
I'm using watir-webdriver to drive IE to test a website using a SSL certificate
I am using watir-webdriver and am attempting to check the background-color of an HTML
I would like to set a text field with watir-webdriver using css selectors to
I'm using Firefox 13 and Watir-webdriver on windows via Ruby 1.9.2 and porting some
I've written an rspec test using Watir against a web application and it's running
I am using rspec and cucumber to run watir tests at sauce labs. I

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.