Manually Adding and Updating Element Locators – The Easy Way

Let me start with some quotes.

“Change is inevitable.”

“The only thing constant is change.”

We have all heard these phrases and variations of these before. It is so very true when it comes to tests. Updating tests can be a horrible experience.

One common task performed is to change the locator/selector of an element used in a command. So far this meant recording that step again or manually figuring out what the locator should be using the html source or tools like Firebug. Not any more! With Selenium IDE v2.5.0, it is just a matter of clicks. Here is how to update the locator for a failing test.

  1. Find the failing command.
    01-Failed test
  2. Click on the command.
    02-Click on command
  3. Click on the Select button next to the locator.
    03-Click on select button
  4. Move to the browser. As you move around the elements will get highlighted.
    04-Move to the browser 05-Move around 06-And around 07-And around 08-And around
  5. When you find the one you are looking for, click on it.
    09-And click on the one you want
  6. In Selenium IDE, the target will be updated automatically.
    10-The locator is updated
  7. If you want to select an alternative locator, you can click on the drop down to get a list to select from.
    11-And you can choose the right locator from the list
  8. Thank me. Enjoy!

Tips:-

  • Once you enter the select mode, the select button changes to a cancel button which can be used to cancel selection of a new element.
  • Once a new element has been selected, you can use undo to go back to the old one. It may require more than one undo.
  • You can also use this select feature to add a locator when manually adding new commands.

I hope you like this feature. As usual, I would love to hear from you.

Follow samitbadle on Twitter

This entry was posted in Selenium Tips and tagged , , , , , , , . Bookmark the permalink.

22 Responses to Manually Adding and Updating Element Locators – The Easy Way

  1. Ed says:

    This sounds awesome….can’t wait to test it out. Thanks!

  2. This is a very good feature. It worked as expected.

    It is noted that Select button (and feature) is not available when Selenium IDE is opened in the Sidebar.

    Thanks for the changes and really appreciate your contribution to the community.

    • Samit Badle says:

      Hi Janesh, Thank you. There is no indication about how many people use the sidebar. Until sufficient people come forward with reports that features are not working in the sidebar, I am afraid the priority for it will be limited.

      Cheers,
      Samit

      • Rene Ruhland says:

        I have the same problem. Use the select button does not work in the sidebar.
        I work exclusively in the sidebar.

        • Samit Badle says:

          Hi Rene,

          Thanks! I was not sure if anyone uses the sidebar anymore. The issue with the sidebar is that there is limited space. I will try to find a solution and get it in the sidebar in the future.

          Cheers,
          Samit

          • Steven Miller says:

            Any news on the sidebar issue yet?
            We too are working with the Selenium IDE in sidebar mode, and this is driving us crazy.

            The limited sidebar space can be changed with a custom user chrome CSS file btw, but that should not be the issue causing the IDE fields not being clickable and not rendering their values.

          • Samit Badle says:

            Hi Steven,

            Selenium IDE 2.8.0 should have the fix.

            Cheers,
            Samit Badle

  3. Steven Kwok says:

    Works brilliantly Samit! I’ve gotten very good at identifying elements manually by inspecting them an identifying them by css (which recording before never did), but this makes it faster and easier. On a side note… I still can’t get IDE-webdriver working with flow control. Was this extension selected for webdriver compatibility?

    • Samit Badle says:

      Hi Steven,

      Thanks! Webdriver does not support extensions. Making the commonly used plugins Webdriver playback compaible, means rewriting them. I had plans of doing so, but the test scheduler in Selenium IDE took priority. Once, it is shipped, I will be back on improving webdriver support in Selenium IDE and the plugins.

      Cheers,
      Samit

  4. Abrar says:

    Anyway to disable this feature?
    As I work on a complex GWT Application which has some dynamic elements.

    • Samit Badle says:

      It is user driven, so unless you click on the button, it does not do anything. Is it interfering with your application if you do not click on it?

      Cheers,
      Samit

  5. Emmanuel Angelo.R says:

    Thanks samit i have been heading into this problem for long time whoa! time to get relive

  6. Jared says:

    This is the greatest thing since sliced bread. Just wish I had installed this new version sooner. Nice work and a thousand thank yous.

  7. pratik says:

    It’s really good feature.I have tried with myself.Really worked.

  8. Ade says:

    Hi,

    Big thanks for the updates.

  9. Jayed Ibrahim says:

    awesome! No need to use firebug then. Thank You.

  10. Gokul Athi says:

    Hi Samit,

    This addon feature looks fantastic. but, found the following inconvenience :

    The ‘Cancel’ button remains intact even on making the necessary selection for the failed locator. I guess, it should revert back to ‘select’

    • Samit Badle says:

      Hi Gokul,

      In my tests, it is working as expected and the cancel button changing to select after you select an element. Please file a bug with details and steps to reproduce on the Selenium project website.

      Cheers,
      Samit

  11. Chris says:

    Hi Samit,

    This is great. I wonder if there is an equivalent version of function in selenium to return the element id or class for the elements that people click on the page? Sometimes things fail because of a sequence of actions people perform, and logging the id would help debugging the site.

    Thanks!
    Chris

    • Samit Badle says:

      Hi Chris,

      I am not sure what you are looking for. You want to find out which elements people click on while running the tests? Probably not. If you just put Selenium IDE in record mode, it should automatically capture the elements that people click on and the click commands would have a list of all the possible locators for the elements. Is that not enough?

      Cheers,
      Samit

Leave a Reply

Your email address will not be published. Required fields are marked *