예제 #1
0
        /// <summary>
        /// Method to check whether Toggle Button(CheckBox/Radio) is checked or not
        /// </summary>
        /// Authour: Vamsi krishna Boyapati
        /// <param name="objMySelenium">Selenium RC Instance</param>
        /// <param name="strLocator">Locator of the Control/Element(Xpath)</param>
        /// <returns>Boolean value(True/False)</returns>

        public bool GetCheckBoxStatus(ISelenium objMySelenium, string strLocator)
        {
            bool bStatus = false;

            try
            {
                if (objMySelenium.IsElementPresent(strLocator))
                {
                    bStatus = objMySelenium.IsChecked(strLocator);
                }
            }
            catch (AutomationException EX)
            {
                Console.WriteLine(EX.Message);
            }
            return(bStatus);
        }
 public void Test_RegisterApprovedUser()
 {
     selenium.SetTimeout("100000");
     selenium.Open("Admin/tests/testreset.aspx");
     selenium.WaitForPageToLoad("30000");
     selenium.Open("Admin/QuickSetup.aspx");
     selenium.WaitForPageToLoad("30000");
     Assert.IsTrue(selenium.IsTextPresent("You are signed in as"), "Text 'You are signed in as' not found when it should be.");
     selenium.Click("link=Settings");
     selenium.WaitForPageToLoad("30000");
     Assert.IsFalse(selenium.IsTextPresent("Exception"), "Text 'Exception' found when it shouldn't be.");
     Assert.IsFalse(selenium.IsTextPresent("aren't authorised"), "Text 'aren't authorised' found when it shouldn't be.");
     selenium.Click("link=User Settings");
     selenium.WaitForPageToLoad("30000");
     if (!selenium.IsChecked("ctl00_Body_ctl00_AutoApproveNewUsers"))
     {
         selenium.Click("ctl00_Body_ctl00_AutoApproveNewUsers");
     }
     selenium.Click("ctl00_Body_ctl00_UpdateButton");
     selenium.WaitForPageToLoad("30000");
     selenium.Click("SignOutLink");
     selenium.WaitForPageToLoad("30000");
     selenium.Click("RegisterLink");
     selenium.WaitForPageToLoad("30000");
     selenium.Type("ctl00_Body_ctl00_FirstName", "Approved");
     selenium.Type("ctl00_Body_ctl00_LastName", "User");
     selenium.Type("ctl00_Body_ctl00_Email", "*****@*****.**");
     selenium.Type("ctl00_Body_ctl00_Username", "approveduser");
     selenium.Type("ctl00_Body_ctl00_Password", "pass");
     selenium.Type("ctl00_Body_ctl00_PasswordConfirm", "pass");
     selenium.Click("ctl00_Body_ctl00_EnableNotifications");
     selenium.Click("ctl00_Body_ctl00_RegisterButton");
     selenium.WaitForPageToLoad("30000");
     Assert.IsTrue(selenium.IsTextPresent("My Details"), "Text 'My Details' not found when it should be.");
     Assert.IsTrue(selenium.IsTextPresent("successfully"), "Text 'successfully' not found when it should be.");
     Assert.IsTrue(selenium.IsTextPresent("*****@*****.**"), "Text '*****@*****.**' not found when it should be.");
     selenium.Open("Admin/tests/testreset.aspx");
     selenium.WaitForPageToLoad("30000");
 }
 public void Test_EnforceUniqueUsername()
 {
     selenium.SetTimeout("100000");
     selenium.Open("Admin/tests/testreset.aspx");
     selenium.WaitForPageToLoad("30000");
     selenium.Open("Admin/QuickSetup.aspx");
     selenium.WaitForPageToLoad("30000");
     Assert.IsTrue(selenium.IsTextPresent("Settings"), "Text 'Settings' not found when it should be.");
     selenium.Click("link=Settings");
     selenium.WaitForPageToLoad("30000");
     selenium.Click("link=User Settings");
     selenium.WaitForPageToLoad("30000");
     if (!selenium.IsChecked("ctl00_Body_ctl00_AutoApproveNewUsers"))
     {
         selenium.Click("ctl00_Body_ctl00_AutoApproveNewUsers");
     }
     selenium.Click("ctl00_Body_ctl00_UpdateButton");
     selenium.WaitForPageToLoad("30000");
     Assert.IsTrue(selenium.IsTextPresent("successfully"), "Text 'successfully' not found when it should be.");
     selenium.Click("SignOutLink");
     selenium.WaitForPageToLoad("30000");
     selenium.Click("RegisterLink");
     selenium.WaitForPageToLoad("30000");
     selenium.Type("ctl00_Body_ctl00_FirstName", "first");
     selenium.Type("ctl00_Body_ctl00_LastName", "last");
     selenium.Type("ctl00_Body_ctl00_Email", "*****@*****.**");
     selenium.Type("ctl00_Body_ctl00_Username", "admin");
     selenium.Type("ctl00_Body_ctl00_Password", "pass");
     selenium.Type("ctl00_Body_ctl00_PasswordConfirm", "pass");
     selenium.Click("ctl00_Body_ctl00_EnableNotifications");
     selenium.Click("ctl00_Body_ctl00_RegisterButton");
     selenium.WaitForPageToLoad("30000");
     selenium.WaitForPageToLoad("30000");
     Assert.IsTrue(selenium.IsTextPresent("username is already in use"), "Text 'username is already in use' not found when it should be.");
     Assert.IsTrue(selenium.IsTextPresent("New User Details"), "Text 'New User Details' not found when it should be.");
     Assert.IsTrue(selenium.IsTextPresent("Register"), "Text 'Register' not found when it should be.");
 }
예제 #4
0
 public void Test_UserSettings()
 {
     selenium.SetTimeout("1000000");
     selenium.Open("Admin/tests/testreset.aspx?Config=true");
     selenium.WaitForPageToLoad("30000");
     selenium.Open("Admin/QuickSetup.aspx");
     selenium.WaitForPageToLoad("30000");
     selenium.Click("link=Settings");
     selenium.WaitForPageToLoad("30000");
     selenium.Click("link=User Settings");
     selenium.WaitForPageToLoad("30000");
     if (selenium.IsChecked("ctl00_Body_ctl00_EnableUserRegistration"))
     {
         selenium.Click("ctl00_Body_ctl00_EnableUserRegistration");
     }
     selenium.Click("//input[@value='Update']");
     selenium.WaitForPageToLoad("30000");
     Assert.IsTrue(selenium.IsTextPresent("updated successfully"), "Text 'updated successfully' not found when it should be.");
     selenium.Click("link=Sign Out");
     selenium.WaitForPageToLoad("30000");
     Assert.IsFalse(selenium.IsTextPresent("Register"), "Text 'Register' found when it shouldn't be.");
     selenium.Open("Edit-UserSettings.aspx");
     Assert.IsTrue(selenium.IsTextPresent("Sign In Details"), "Text 'Sign In Details' not found when it should be.");
 }
 public void Test_EditOwnAccount()
 {
     selenium.SetTimeout("100000");
     selenium.Open("Admin/tests/testreset.aspx");
     selenium.WaitForPageToLoad("30000");
     selenium.Open("Admin/QuickSetup.aspx");
     selenium.WaitForPageToLoad("30000");
     Assert.IsTrue(selenium.IsTextPresent("Settings"), "Text 'Settings' not found when it should be.");
     selenium.Click("link=Settings");
     selenium.WaitForPageToLoad("30000");
     Assert.IsTrue(selenium.IsTextPresent("User Settings"), "Text 'User Settings' not found when it should be.");
     selenium.Click("link=User Settings");
     selenium.WaitForPageToLoad("30000");
     selenium.WaitForPageToLoad("30000");
     if (!selenium.IsChecked("ctl00_Body_ctl00_AutoApproveNewUsers"))
     {
         selenium.Click("ctl00_Body_ctl00_AutoApproveNewUsers");
     }
     selenium.Click("ctl00_Body_ctl00_UpdateButton");
     selenium.WaitForPageToLoad("30000");
     selenium.WaitForPageToLoad("30000");
     Assert.IsTrue(selenium.IsTextPresent("successfully"), "Text 'successfully' not found when it should be.");
     selenium.Click("SignOutLink");
     selenium.WaitForPageToLoad("30000");
     selenium.Click("RegisterLink");
     selenium.WaitForPageToLoad("30000");
     selenium.Type("ctl00_Body_ctl00_FirstName", "Approved");
     selenium.Type("ctl00_Body_ctl00_LastName", "User");
     selenium.Type("ctl00_Body_ctl00_Email", "*****@*****.**");
     selenium.Type("ctl00_Body_ctl00_Username", "testuser");
     selenium.Type("ctl00_Body_ctl00_Password", "pass");
     selenium.Type("ctl00_Body_ctl00_PasswordConfirm", "pass");
     selenium.Click("ctl00_Body_ctl00_EnableNotifications");
     selenium.Click("ctl00_Body_ctl00_RegisterButton");
     selenium.WaitForPageToLoad("30000");
     selenium.WaitForPageToLoad("30000");
     Assert.IsTrue(selenium.IsTextPresent("My Details"), "Text 'My Details' not found when it should be.");
     Assert.IsTrue(selenium.IsTextPresent("successfully"), "Text 'successfully' not found when it should be.");
     Assert.IsTrue(selenium.IsTextPresent("*****@*****.**"), "Text '*****@*****.**' not found when it should be.");
     selenium.Click("//input[@id='ctl00_Body_ctl00_ViewEditButton']");
     selenium.WaitForPageToLoad("30000");
     selenium.WaitForPageToLoad("30000");
     Assert.IsFalse(selenium.IsTextPresent("Exception"), "Text 'Exception' found when it shouldn't be.");
     Assert.IsTrue(selenium.IsTextPresent("First Name:"), "Text 'First Name:' not found when it should be.");
     selenium.Type("ctl00_Body_ctl00_FirstName", "NewFirst");
     selenium.Type("ctl00_Body_ctl00_LastName", "NewLast");
     selenium.Type("ctl00_Body_ctl00_Email", "*****@*****.**");
     selenium.Click("ctl00_Body_ctl00_UpdateButton");
     selenium.WaitForPageToLoad("30000");
     selenium.WaitForPageToLoad("30000");
     Assert.IsTrue(selenium.IsTextPresent("My Details"), "Text 'My Details' not found when it should be.");
     Assert.IsTrue(selenium.IsTextPresent("updated successfully"), "Text 'updated successfully' not found when it should be.");
     Assert.IsTrue(selenium.IsTextPresent("NewFirst"), "Text 'NewFirst' not found when it should be.");
     Assert.IsTrue(selenium.IsTextPresent("NewLast"), "Text 'NewLast' not found when it should be.");
     Assert.IsTrue(selenium.IsTextPresent("*****@*****.**"), "Text '*****@*****.**' not found when it should be.");
     selenium.Click("SignOutLink");
     selenium.WaitForPageToLoad("30000");
     selenium.Type("ctl00_Body_ctl00_Login_UserName", "testuser");
     selenium.Type("ctl00_Body_ctl00_Login_Password", "pass");
     selenium.Click("ctl00_Body_ctl00_Login_LoginButton");
     selenium.WaitForPageToLoad("30000");
     Assert.IsTrue(selenium.IsTextPresent("Sign Out"), "Text 'Sign Out' not found when it should be.");
     Assert.IsTrue(selenium.IsTextPresent("My Details"), "Text 'My Details' not found when it should be.");
     Assert.IsTrue(selenium.IsTextPresent("You are signed in as:"), "Text 'You are signed in as:' not found when it should be.");
 }
예제 #6
0
 ///<summary>
 /// This method check/unchecks the check box
 /// <example>SelectCheckbox(browser, xPath, On/Off)</example>       
 public void SelectCheckbox(ISelenium browserObj, string strLocator, string value)
 {
     try
     {
         Assert.IsTrue(browserObj.IsVisible(strLocator), strLocator + " element is not present");
         if (value.ToLower().Trim() == "on")
         {
             if (!browserObj.IsChecked(strLocator))
             {
                 browserObj.Check(strLocator);
                 CFframeworkCommonObj.PageSync(browserObj);
                 if (!(browserObj.IsChecked(strLocator)))
                 {
                     Console.WriteLine("Failed to check the checkbox - " + strLocator);
                     Fail("Failed to check the checkbox - " + strLocator);
                 }
             }
         }
         else
         {
             browserObj.Uncheck(strLocator);
             CFframeworkCommonObj.PageSync(browserObj);
             if (browserObj.IsChecked(strLocator))
             {
                 Console.WriteLine("Failed to Uncheck the checkbox - " + strLocator);
                 Fail("Failed to check the Uncheckbox - " + strLocator);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Function 'SelectCheckbox' - Failed");
         Console.WriteLine(ex.Message);
         Fail(ex.Message);
     }
 }
예제 #7
0
 /// <summary>
 /// Returns whether the specified checkbox/ radio button is checked or not
 /// </summary>
 /// <param name="locator">The locator.</param>
 /// <param name="type">Type of locator</param>
 /// <returns>
 /// true if checked, false otherwise
 /// </returns>
 public bool IsChecked(string locator, FindType type = FindType.ById)
 {
     return(_selenium.IsChecked(locator));
 }