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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:11:45+00:00 2026-05-22T12:11:45+00:00

I’m writing an application with Watin. Its great, but running a performance analysis on

  • 0

I’m writing an application with Watin. Its great, but running a performance analysis on my program, over 50% of execution time is spent looping through lists of elements.

For example:
foreach (TextField bT in browser.TextFields)
{

Is very slow.

I seem to remember seeing somewhere there is a faster way of doing this in WatiN, but unfortunately I can’t find the page again.

Accessing the number of elements also seems to be slow, eg;
browser.CheckBoxes.Count

Thanks for any tips,
Chris

  • 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-22T12:11:46+00:00Added an answer on May 22, 2026 at 12:11 pm

    I think I could answer you better if I had a better idea of what you were trying to do, but I can share some observations on what I’ve learned with WatiN so far.

    The more specific your selectors are, the faster things will go. Avoid using “browser.Elements” as that is really generic. I’m not sure that it saves much, but doing something like browser.Body.Elements throws the header elements out of the scope of things to check and may save a few calculations.

    When I say “scope”, consider that WatiN always starts with the entire DOM. Can you think of ways to limit the scope of elements perhaps to the text fields within the main div on your page? WatiN returns Elements and ElementCollections, each of which may have its own ElementCollection. That div probably has a specific ID, so you can do something like

    var textFields = ie.Div("divId").TextFields;
    

    Look for opportunities to be more specific, and you can use LINQ to describe what you want more clearly. For example, can you write something like:

    ie.Body.TextFields.
      Where(tf => !string.IsNullOrWhiteSpace(tf.ClassName) && tf.ClassName.Contains("classname")).ToList().
      Foreach(tf => tf.Value = "Your Text");
    

    I would refine that further by reducing the number of times I scan the collection by doing something like:

    ie.Body.TextFields.ToList().
      Foreach(tf => {
        if(!string.IsNullOrWhiteSpace(tf.ClassName) && tf.ClassName.Contains("classname")) { 
          tf => tf.Value = "Your Text"
        }
      });
    

    The “Find.By*” specifiers also help WatiN operate on the collections you want faster and are a more elegant short-hand for what I wrote above:

    ie.Body.TextFields.Filter(Find.ByClass("class")).ToList().ForEach(tf => tf.Value = "Your Text");
    

    And as a last piece of advice, this project lets you find elements using jQuery/CSS style selectors.

    So, tl;dr: Narrow down the scope of what you’re looking for, and be specific.

    Hope that helps. I’m looking for ways to speed up my own tests.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from
I want to construct a data frame in an Rcpp function, but when I
I am writing an app with both english and french support. The app requests
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.