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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:44:50+00:00 2026-06-10T10:44:50+00:00

Looking at Knockout examples, there is no real need for adding IDs to HTML

  • 0

Looking at Knockout examples, there is no real need for adding IDs to HTML elements. Creating a large form without the IDs seems to make it easy to maintain.

Though, this creates a problem with Selenium HQ. There is no way to uniquely identify elements on the form.

What are the choices? Is there another method for Selenium to select elements created by Knockout?
or will I have to assign IDs to elements?

I have reviewed other knockout and selenium questions. All of them had IDs defined for the HTML elements, when they started.

Thanks
Abhi

  • 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-10T10:44:52+00:00Added an answer on June 10, 2026 at 10:44 am

    Short answer: Add ID’s to your HTML elements.

    Although you do not need these attributes in order for your website to function, you will make the life of your testers so much easier.

    I’ve encountered the exact same problem in a project where a large ASP.NET MVC 4 application was created, that uses Knockout.js and Selenium extensively. For form elements, I relied on ASP.NET MVC utility methods to generate the output HTML in combination with data-bind expressions. ASP.NET MVC automatically generates unique NAME and ID attributes based on the backing model.

    However, in all other cases where I had to render tables, display forms or dialogs, I ended up adding ID attributes to these HTML elements. If you think about it, this is a logical consequence of your requirements. Knockout is awesome because you longer need ID’s and NAME’s to wire your layout (HTML) and behavior (JS) together. However, other frameworks, such as Selenium, require these ID’s to be present.

    Yes, you could work your way around it with complicated and bloated XPATH expressions. But this will dramatically decrease the maintainability of your tests. In my experience, adding ID’s to hundreds of HTML elements took less than a day and increased productivity of our testers by a manifold.

    Remember, it may be nice to develop functional websites with as little HTML as possible. But if this makes your website untestable, you will lose more than you gain. Testability is non-functional requirement, but this does not mean it is not important!

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

Sidebar

Related Questions

I was looking at the Contacts editor sample on the knockout.js website: http://knockoutjs.com/examples/contactsEditor.html The
Looking at all the examples of Operational Transformation Frameworks out there, they all seem
I'm looking through the knockout tutorials, and all the examples create the view model
Looking at the Slickgrid examples and using Google Chrome, I'm setting a breakpoint on
Looking at some of the code System.Linq I've come across some examples of Buffer<TSource>
Looking for a general case solution to determine if any jquery dialog (there are
Looking through the achievement list for Visual Studio 2010, it says that there is
I am trying to understand what Knockout does to elements on the page when
Today I was looking into Knockout JavaScript library and its features. Now I want
I've started looking into using Knockout for my team's use; I've been very pleased

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.