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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:39:09+00:00 2026-05-20T00:39:09+00:00

Here’s the situation that I’m working with: Build tests in Selenium Get all the

  • 0

Here’s the situation that I’m working with:

  • Build tests in Selenium
  • Get all the tests running correctly (in Firefox)
  • Export all the tests to MSTest (so that each test can be run in IE, Chrome and FF)
  • If any test needs to be modified, do that editing in Selenium IDE

So it’s a very one-way workflow. However, I’d now like to do a bit more automation. For instance, I’d like every test to run under each of two accounts. I’m getting into a maintenance issue. If I have 6 tests that I want to run under two accounts, suddenly I’d need 12 tests in the Selenium IDE tests. That’s too much editing. But a ton of that code is exactly the same.

How can I share chunks of Selenium tests among tests? Should I use Selenium IDE to develop the test first time then never use it again (only doing edits in VS after that)?

  • 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-20T00:39:10+00:00Added an answer on May 20, 2026 at 12:39 am

    Selenium code is very linear after you export it from the IDE.

    For example (ignore syntax):

      someTestMethod() {
         selenium.open("http://someLoginPage.com");
         selenium.type("usernameField", "foo");
         selenium.type("passwordField", "bar");
         selenium.click("loginButton");
         selenium.waitForPageToLoad("30000");
         assertTrue(selenium.isTextPresent("Welcome * foo"));
      }
    

    This is the login page. Every single one of your tests will have to use it. You should refactor it into a method.

      someTestMethod(){
         selenium.open("http://someLoginPage.com");
         String username = "foo";
         String password = "bar";
         performLogin(username, password);
      }
    
      performLogin(String username, String password){
          selenium.type("usernameField", username);
          selenium.type("passwordField", password);
          selenium.click("loginButton");
          selenium.waitForPageToLoad("30000");
          assertTrue(selenium.isTextPresent("Welcome * foo"));
      }
    

    The performLogin() method does not have to be in the same file as your test code itself. You can create a separate class for it with your methods and share it between your tests.

    We have classes that correspond to certain functionalities on our UI. For example, we have many ways to search in our app. All methods that helps you with search functionality will be in the SearchUtil class.

    Structuring your tests similarly will give you the following advantages:

    • If the UI changes (an id of a field), you go to your one method, update the id and you are good to go
    • If the flow of your logic changes you also have only one place to update
    • To test whether your changes worked, you only have to run one of the tests to verify. All other tests use the same code so it should work.
    • A lot more expressive as you look at the code. With well named methods, you create a higher level of abstraction that is easier to read and understand.
    • Flexible and extensible! The possibilities are limitless. At this point you can use conditions, loops, exceptions, you can do your own reporting, etc…

    This website is an excellent resource on what you are trying to accomplish.

    Good Luck!

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

Sidebar

Related Questions

Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here's a coding problem for those that like this kind of thing. Let's see
Here is the scenario: I'm writing an app that will watch for any changes
Here, i have coded to get data from DB. I want to store the
I'm getting an error here that says I haven't defined a method, but it
This is beyond both making sense and my control. That being said here is
here a a piece of code that is supposed to loop over and over
Here I had a problem that I am adding contact from the address book

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.