Exemple #1
0
        public void Login(string userName, string passWord)
        {
            // Find the text input element by its name
            IWebElement username = browser.FindElement(By.Id("UserName"));

            Libary.HighLight(browser, username);
            username.SendKeys(userName);

            IWebElement password = browser.FindElement(By.Id("Password"));

            Libary.HighLight(browser, password);

            //IE browser password need encrypted
            // password.SendKeys(passWord);

            //Workaround use Java Script to enter password
            //((IJavaScriptExecutor)browser).ExecuteScript("document.getElementById('Password').value = '12@safe'");
            var encryptedPassword = "******" + passWord + "'";

            ((IJavaScriptExecutor)browser).ExecuteScript(encryptedPassword);

            IWebElement signin = browser.FindElement(By.Id("btnSignIn"));

            Libary.HighLight(browser, signin);
            signin.Click();
        }
Exemple #2
0
        private void Save()
        {
            IWebDriver browser = TestRunnerInterface.Map.safePage.browser;

            //Find the parent table element
            //Then find child element element
            //Libary.WaitForElementByID(browser, "tblDocumentsOnFile", RunTimeVars.PAGELOADWAIT);
            //IWebElement element1 = browser.FindElement(By.Id("tblDocumentsOnFile"));

            IWebElement element1 = Libary.GetPageElement(browser, RunTimeVars.ELEMENTSEARCH.ID, "tblDocumentsOnFile", RunTimeVars.REPEAT_TIMES);
            IWebElement save     = element1.FindElement(By.XPath("//input[@type='submit' and @value='Save']"));

            Libary.HighLight(browser, save);

            //save.Click();

            // Move cursor to the Main Menu Element
            //Actions action = new Actions(browser);
            //action.MoveToElement(save).ClickAndHold().Build().Perform();

            //The button is tied to Javascript onclick event
            //use Javascript to click the button
            //<input type="submit" value="Save" onclick="OnSaveClick();">

            IJavaScriptExecutor jscript = (IJavaScriptExecutor)browser;

            jscript.ExecuteScript("arguments[0].click();", save);
        }
Exemple #3
0
        /// <summary>
        /// The change password page is already displayed
        /// </summary>
        /// <param name="role"></param>
        public void UpdatePassword(string role)
        {
            //Get current password based on User Role
            var result = AppConfig.GetAppSectionValue(role);

            string[] userPwd     = result.Split(',');
            var      oldPassWord = userPwd[1];

            //Get new password
            var newPassWord = AppConfig.GetAppSectionValue("NewPassword");

            //IE browser password need encrypted
            // password.SendKeys(passWord);

            IWebElement OldPassword = browser.FindElement(By.Id("OldPassword"));
            //Workaround use Java Script to enter old password
            //((IJavaScriptExecutor)browser).ExecuteScript("document.getElementById('OldPassword').value = '12@safe'");
            var encryptedPassword = "******" + oldPassWord + "'";

            ((IJavaScriptExecutor)browser).ExecuteScript(encryptedPassword);

            IWebElement NewPassword = browser.FindElement(By.Id("NewPassword"));

            //Workaround use Java Script to enter old password
            //((IJavaScriptExecutor)browser).ExecuteScript("document.getElementById('newPassword').value = '12@safe'");
            encryptedPassword = "******" + newPassWord + "'";
            ((IJavaScriptExecutor)browser).ExecuteScript(encryptedPassword);

            IWebElement ConfirmPassword = browser.FindElement(By.Id("ConfirmPassword"));

            //Workaround use Java Script to enter old password
            //((IJavaScriptExecutor)browser).ExecuteScript("document.getElementById('confirmPassword').value = '12@safe'");
            encryptedPassword = "******" + newPassWord + "'";
            ((IJavaScriptExecutor)browser).ExecuteScript(encryptedPassword);

            //IWebElement element = browser.FindElement(By.CssSelector("img[alt='Save']"));
            IWebElement changeButton = browser.FindElement(By.XPath("//input[@src ='/portal/Content/Images/change.gif']"));

            Libary.HighLight(browser, changeButton);
            changeButton.Click();

            //Switch to the Conformation Dialog
            IWebElement closeButton = browser.FindElement(By.XPath("//span[contains(.,'Close')]"));

            Libary.HighLight(browser, closeButton);

            closeButton.Click();
        }
Exemple #4
0
        /// <summary>
        /// Using Implicit Wait Time
        /// </summary>
        /// <param name="seconds"></param>
        public void WaitForPageLoad(int seconds)
        {
            /*************************************
             * Switch from WebDriver Explicit Wait to Implicit Wait
             * WebDriverWait wait = new WebDriverWait(browser, TimeSpan.FromSeconds(seconds));
             * //Get the Browser Window Title
             * var browserWindowText = browser.Title;
             *
             * wait.Until(ExpectedConditions.ElementIsVisible(By.LinkText("Change Name")));
             * //wait.Until((d) => { return d.Title.ToLower().StartsWith("books"); });
             ****************************************/

            IWebElement changeName = browser.FindElement(By.LinkText("Change Name"));

            Libary.HighLight(browser, changeName);
        }
        public void AddService(string service)
        {
            IWebDriver browser = TestRunnerInterface.Map.safePage.browser;

            //Select the service
            //SelectElement select = new SelectElement(browser.FindElement(By.Id("slServiceTypes"))); //Locating select list

            IWebElement   serviceTypes = Libary.GetPageElement(browser, RunTimeVars.ELEMENTSEARCH.ID, "slServiceTypes", RunTimeVars.REPEAT_TIMES);
            SelectElement select       = new SelectElement(serviceTypes);

            Libary.HighLight(browser, serviceTypes);

            select.SelectByText(service.Trim()); //Select item from list having option text as "Item1"

            //click the transfer button
            browser.FindElement(By.Id("addButton")).Click();
        }
Exemple #6
0
        /// <summary>
        /// Using Implicit Wait Time
        /// </summary>
        /// <param name="seconds"></param>
        public void WaitForSafeHomePage(int repeat_times)
        {
            /*********** comment out **********
            * Switch from WebDriver Explicit Wait to Implicit Wait
            *  WebDriverWait wait = new WebDriverWait(browser, TimeSpan.FromSeconds(seconds));
            *  //Get the Browser Window Title
            *  var browserWindowText = browser.Title;
            *
            *  wait.Until(ExpectedConditions.ElementIsVisible(By.LinkText("Change Name")));
            *  //wait.Until((d) => { return d.Title.ToLower().StartsWith("books"); });
            *
            *  IWebElement changeName = browser.FindElement(By.LinkText("Change Name"));
            *  Libary.HighLight(browser, changeName);
            *********** comment out **********/

            var controlWaitTime = repeat_times;

            while (controlWaitTime > 0)
            {
                try
                {
                    IWebElement changeName = browser.FindElement(By.LinkText("Change Name"));
                    Libary.HighLight(browser, changeName);
                    break;
                }
                catch
                {
                    System.Threading.Thread.Sleep(1 * 1000); //Wait 1-sec
                    controlWaitTime--;
                    continue;
                }
            }

            //Check if(Page displayed <= controlWaitTime)
            if (controlWaitTime <= 0)
            {
                throw new Exception("Safe Home Page Not Displayed...");
            }
        }