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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:24:27+00:00 2026-05-24T23:24:27+00:00

I am exploring the use of Selenium 2 on a web application which requires

  • 0

I am exploring the use of Selenium 2 on a web application which requires authentication before a user can use any of the application. I am planning on either JUnit 4 or TestNG (Still investigating which one to use with Grid 2). I may plan to use jbehave as well.

Does anyone have any suggestions on how I can improve the following test so I can use successful login functionality across all my tests? I want to avoid duplicating login in the tests itself.

public class LoginPageTest {

    private LoginPage page;

    @Before
    public void openTheBrowser() {
        page = PageFactory.initElements(new FirefoxDriver(), LoginPage.class);
        page.open("http://www.site.com/Login");
    }

    @After
    public void closeTheBrowser() {
        page.close();
    }

    @Test
    public void whenTheUserEntersValidCredentialsTheUserIsLoggedIn() {
        assertThat(page.getTitle(), containsString("Login") );
    }   
}

The test is simplified but it will return a page object of a successful login.

thanks

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

    Your best option might be to use the LoginPageTest class as a parent class and extend each of your test classes from LoginPageTest.

    That way, each test can login to the system using the parent’s setup and tear down methods and do its own additional testing as well.

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

Sidebar

Related Questions

I have an Internet Explorer only web application. I'm exploring what we can do
I am making a desktop application and I am exploring different ways to use
I've been exploring use of MSys lately as an alternative, 'nix-like shell for my
I'm exploring the possibility of writing an application in Erlang, but it would need
I'm exploring the XML -> XSLT -> HTML meme for producing web content. I
I'm learning Java programming and right now I'm exploring the use of objects in
I try to use rails 3.1 ActiveModel::SecurePassword by following http://bcardarella.com/post/4668842452/exploring-rails-3-1-activemodel-securepassword and I end up
I am now exploring to use Apache's mod_proxy's directive, eg ProxyPass, as part of
I'm exploring Sinatra and I want to use sessions but I don't want them
I found storeHtmlSource method description in Selenium reference , but can't figure out how

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.