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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:02:27+00:00 2026-05-28T05:02:27+00:00

i made a success selenium test case for login page , which a user

  • 0

i made a success selenium test case for login page, which a user enters a correct username and password and then hit login to forwarded to home page,issue is that when i change the password in the test class, the test always success i don’t know why.

here’s the test Class:

public class LoginTest extends TestCase {

    private WebDriver driver;
    private String baseUrl;
    private StringBuffer verificationErrors = new StringBuffer();

    @Before
    public void setUp() throws Exception {
        driver = new FirefoxDriver();
        baseUrl = "http://localhost:8080";
    }

    @Test
    public void testLoginClass() throws Exception {
        driver.get(baseUrl + "/MyAPP/login");
        driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

        driver.findElement(By.id("j_username")).clear();
        driver.findElement(By.id("j_username")).sendKeys("1");
        driver.findElement(By.id("j_password")).clear();
        driver.findElement(By.id("j_password")).sendKeys("wrong password");
        driver.findElement(By.id("loginBtn")).click();

    }

    @After
    public void tearDown() throws Exception {
        driver.quit();
        String verificationErrorString = verificationErrors.toString();
        if (!"".equals(verificationErrorString)) {
            fail(verificationErrorString);
        }
    }

    @SuppressWarnings("unused")
    private boolean isElementPresent(By by) {
        try {
            driver.findElement(by);
            return true;
        } catch (NoSuchElementException e) {
            return false;
        }
    }

}

please advise how to handle the fail of test case, let’s suppose that after sometime the database is changed and there’s no such user 1 which is success right now.

  • 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-28T05:02:27+00:00Added an answer on May 28, 2026 at 5:02 am

    Your not checking to see if the wrong password got the user logged in.

    You need to put a test case to check after logging in, if some particular text appears.

    Like for example, if the user successfully logs in, the welcome screen shows “Hi UserName”. So you need to assert if the text is present after your selenium script hits on the loginBtn

    Currently all you are doing is sending “some” text as the password, selenium will obviously not know if the password is incorrect, unless you validate the outcome of entering an incorrect password.

    Edit


    A code snippet in RUBY-

    assert(@driver.find_element(:tag_name => "body").text.include?("Welcome UserName"),"The User successfully logs in")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made an html file called test.html then I navigated to it as http://site.com/test.html?test1=a
I have made a form which adds controls dynamically with user selecting the type
Can we Made an anchor tag autoclick in the success function of Ajax Script?
I have made my own custon vtype which performs an ajax request to check
I'm trying some time, but without success. I made some circle with animation that
I have data in which each participant made 3 judgments on each of 9
Unfortunately I can't post link here to which post request is made to. But
I've got a mad problem with an application I test with Selenium RC At
I would like to have the Notification like if the transaction made is success
I followed the StockWatcher GWT tutorial with success and made the integration with GAE

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.