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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:26:42+00:00 2026-05-11T23:26:42+00:00

We use Selenium to test the UI layer of our ASP.NET application. Many of

  • 0

We use Selenium to test the UI layer of our ASP.NET application. Many of the test cases test longer flows that span several pages.

I’ve found that the tests are very brittle, broken not just by code changes that actually change the pages but also by innocuous refactorings such as renaming a control (since I need to pass the control’s clientID to Selenium’s Click method, etc) or replacing a gridview with a repeater. As a result I find myself “wasting” time updating string values in my test cases in order to fix broken tests.

Is there a way to write more maintainable Selenium tests? Or a better web UI testing tool?

Edited to add:
Generally the first draft is created by recording a test in the IDE. (This first step may be performed by QA staff.) Then I refactor the generated C# code (extract constants, extract methods for repeated code, maybe repeat the test case with different data, etc). But the general flow of code for each test case remains reasonably close to the originally generated code.

  • 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-11T23:26:42+00:00Added an answer on May 11, 2026 at 11:26 pm

    I’ve found PageObject pattern very helpful.

    http://code.google.com/p/webdriver/wiki/PageObjects

    more info:
    – What's the Point of Selenium?
    – Selenium Critique

    maybe a good way to start is to incrementally refactor your test cases.

    I use the same scenario you have selenium + c#

    Here is how my code looks like:

    A test method will look like somethink like this

        [TestMethod]
        public void RegisterSpecialist(UserInfo usrInfo, CompanyInfo companyInfo)
        {
            var RegistrationPage = new PublicRegistrationPage(selenium)
                  .FillUserInfo(usrInfo)
                  .ContinueSecondStep();
            RegistrationPage.FillCompanyInfo(companyInfo).ContinueLastStep();
            RegistrationPage.FillSecurityInformation(usrInfo).ContinueFinishLastStep();
            Assert.IsTrue(RegistrationPage.VerifySpecialistRegistrationMessagePayPal());
            selenium.WaitForPageToLoad(Resources.GlobalResources.TimeOut);
            paypal.LoginSandboxPage(usrInfo.sandboxaccount, usrInfo.sandboxpwd);
            Assert.IsTrue(paypal.VerifyAmount(usrInfo));
            paypal.SubmitPayment();
            RegistrationPage.GetSpecialistInformation(usrInfo);
            var bphome = new BPHomePage(selenium, string.Format(Resources.GlobalResources.LoginBPHomePage, usrInfo.AccountName, usrInfo.Password));
            Assert.IsTrue(bphome.VerifyPageWasLoaded(usrInfo));
            Assert.IsTrue(bphome.VerifySpecialistProfile());
            bphome.Logout();
        }
    

    A page Object will be something like this

    public class PublicRegistrationPage
    {
        public ISelenium selenium { get; set; }
    
        #region Constructors
        public PublicRegistrationPage(ISelenium sel)
        {
            selenium = sel;
            selenium.Open(Resources.GlobalResources.PublicRegisterURL);
        }
        #endregion
        #region Methods
    
        public PublicRegistrationPage FillUserInfo(UserInfo usr)
        {
            selenium.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserFirstName", usr.FirstName);
            selenium.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserLastName", usr.LastName);
            selenium.Select("ctl00_cphComponent_ctlContent_wizRegister_ddlUserCountry", string.Format("label={0}",usr.Country ));
            selenium.WaitForPageToLoad(Resources.GlobalResources.TimeOut);
            selenium.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserEmail", usr.Email );
            selenium.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserDirectTel", usr.DirectTel);
            selenium.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserMobile", usr.Mobile);
            return this;
        }
    

    }

    Hope this helps.

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

Sidebar

Related Questions

I use selenium-rc to test an asp.net website, test script is written in Python
I have a Selenium IDE (version 1.7.2) test that I use to test the
We would like to use Selenium to test email content generated from our website.
We use SpecFlow with Selenium successfully to test our HTML applications and are looking
I'm migrating our Selenium test to WebDriver and there is a test which use
So, I've started to create some Ruby unit tests that use Selenium RC to
Is it possible to create Selenium tests using the Firefox plugin that use randomly
We are using JUnit - Selenium for our web tests. We use Maven to
I am designing a test application (Using NUnit) that will have to navigate (through
I use Selenium to test some web-product in my company. Product has button, which

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.