FenWangNZ / blog

I love learning. This is my wiki.
0 stars 0 forks source link

Second refactoring of Login Module(6 test methods) #9

Open FenWangNZ opened 3 years ago

FenWangNZ commented 3 years ago

Add more tests for login module:

After I completed the Login Module tests. There are 6 tests in total.

    [TestMethod]
    [Description("Validate that the user is able to login successfully using validate data")]
    public void Test_1()
    {
        userInfo.EmailAddress = ["guest@guest.com](mailto:%22guest@guest.com)";
        userInfo.PassWord = "q1111111";
        loginPage.InputUserInfoAndLogin(userInfo);
        Assert.AreEqual("CBA Invoicing", driver.Title);
    }

    [TestMethod]
    [Description("Validate alert if there is no input into email address and password fields")]
    public void Test_0_NoInput()
    {
        loginPage.NoInput();
        Assert.IsTrue(loginPage.AlertforEmailAddress.Text.Contains("You Must Enter A Value."));
        Assert.IsTrue(loginPage.AlertforPassword.Text.Contains("You Must Enter A Value."));
        Assert.IsFalse(loginPage.LoginButton.Enabled);

    }

    [TestMethod]
    [Description("Validate that the user will get an alert while only inputting password field ")]
    public void Test_0_OnlyInputPassword()
    {
        userInfo.PassWord = "q1111111";
        loginPage.PassWord.SendKeys(userInfo.PassWord);
        loginPage.LoginButton.Click();
        Assert.IsFalse(loginPage.LoginButton.Enabled);
    }

    [TestMethod]
    [Description("Validate that the user will get an alert while only inputting email address field ")]
    public void Test_0_OnlyInputEmailAddress()
    {
        userInfo.EmailAddress = "guest@guest.com";
        loginPage.EmailAddress.SendKeys(userInfo.EmailAddress);
        loginPage.LoginButton.Click();
        Assert.IsFalse(loginPage.LoginButton.Enabled);
    }

    [TestMethod]
    [Description("Validate that the user is not able to login successfully using invalid data")]
    public void Test_0_WrongPassword()
    {
        userInfo.EmailAddress = "guest@guest.com";
        userInfo.PassWord = "guest111";

        loginPage.InputUserInfoAndLogin(userInfo);
        Thread.Sleep(3000);
        driver.SwitchTo().Alert().Accept();
        Assert.AreEqual("Login to Your Account!", loginPage.LoginToYourAccount.Text);
    }

    [TestMethod]
    [Description("Validate that the user will get an alert if inputting an inexisting email address")]
    public void Test_0_InputWrongEmailAddress()
    {
        userInfo.EmailAddress = "guest@opeu.com";
        userInfo.PassWord = "guest111";

        loginPage.InputUserInfoAndLogin(userInfo);
        Thread.Sleep(3000);
        driver.SwitchTo().Alert().Accept();
        Assert.AreEqual("Login to Your Account!", loginPage.LoginToYourAccount.Text);
    }

It looks tidier than when I haven't learnedt automation framework. I love programming. Tomorrow I will start the Invoice Module and then finish up with Logging and Reporting. Here is the running results. Screen Shot 2020-10-26 at 11 18 14 PM