Ejemplo n.º 1
0
        public void CreateCourseWithoutCourseName()
        {
            string pos = selenium.GetLocation();

            selenium.WaitForPageToLoad("40000");
            selenium.Click("link=Create New");
            selenium.WaitForPageToLoad("40000");
            selenium.Click("css=input[value=\"Create\"]");
            Assert.AreEqual(pos, selenium.GetLocation());
        }
Ejemplo n.º 2
0
 private void handleKnownTestException(Exception e)
 {
     Console.Error.Write("Details: ");
     if (e.Message.Length > 0)
     {
         Console.Error.WriteLine(e.Message);
         if (Regex.IsMatch(e.Message, "ERROR: Element .* not found"))
         {
             Console.Error.WriteLine("Location:" + selenium.GetLocation());
             Console.Error.WriteLine("Page title: " + selenium.GetTitle());
             Console.Error.WriteLine("Fields are:");
             foreach (var field in selenium.GetAllFields())
             {
                 Console.Error.WriteLine(field);
             }
         }
     }
     else if (e is AssertionException)
     {
         Console.Error.WriteLine("Assertion failed. No message provided.");
     }
     else
     {
         Console.Error.WriteLine(
             "No useful exception message. Try to improve exception handling in WebTester once underlying problem is discovered. Main exception ToString: " + e);
     }
 }
Ejemplo n.º 3
0
        public void RegisterInvalid()
        {
            selenium.Open("/");
            selenium.Click("link=Register");
            selenium.WaitForPageToLoad("30000");

            var guid = Guid.NewGuid();
            var name = guid.ToString().Replace('-', '_').Substring(0, 12);

            selenium.Type("id=Name", "nestor");
            selenium.Click("//input[@value='Register']");
            selenium.WaitForPageToLoad("30000");
            Assert.IsTrue(selenium.GetLocation().EndsWith("/Account/Register"));
        }
Ejemplo n.º 4
0
        public void CreateUserSuccess()
        {
            selenium.Open("/");
            selenium.Type("id=loginPassword", "lex");
            selenium.Type("id=loginUsername", "lex");
            selenium.Click("//div[@id='logindisplay']/form[2]/input[3]");
            selenium.WaitForPageToLoad(UpgradeSeleniumTester.browserWait);

            var guid = Guid.NewGuid();
            var name = guid.ToString().Replace('-', '_').Substring(0, 12);

            selenium.Click("//a[contains(@href, '/User/Index')]");
            selenium.WaitForPageToLoad(UpgradeSeleniumTester.browserWait);
            selenium.Click("//a[contains(@href, '/User/Create')]");
            selenium.WaitForPageToLoad(UpgradeSeleniumTester.browserWait);
            selenium.Type("id=Username", "un_" + name);
            selenium.Type("id=Password", "1");
            selenium.Type("id=Email", "*****@*****.**");
            selenium.Type("id=Name", "name");
            selenium.Type("id=UserId", "id_" + name);
            selenium.Click("//input[@value='Create']");
            selenium.WaitForPageToLoad(UpgradeSeleniumTester.browserWait);
            Assert.IsTrue(selenium.GetLocation().EndsWith("/User/Index"));
        }
        private void AssertCorrectPageLoaded <TT>(TT target) where TT : PageBase
        {
            var location    = _selenium.GetLocation();
            var paramsStart = location.IndexOf('?');

            if (paramsStart >= 0)
            {
                location = location.Substring(0, paramsStart);
            }

            if (!location.EndsWith(target.PageUrl))
            {
                Assert.Fail("Expected URL {0} but was {1}", target.PageUrl, location);
            }
        }
Ejemplo n.º 6
0
        public void LoginWithOpenIdSuccess()
        {
            selenium.Open("/");
            selenium.Type("id=loginPassword", "lex");
            selenium.Type("id=loginUsername", "lex");
            selenium.Click("//div[@id='logindisplay']/form[2]/input[3]");
            selenium.WaitForPageToLoad(UpgradeSeleniumTester.browserWait);

            var guid = Guid.NewGuid();
            var name = guid.ToString().Replace('-', '_').Substring(0, 12);

            selenium.Click("//a[contains(@href, '/User/Index')]");
            selenium.WaitForPageToLoad(UpgradeSeleniumTester.browserWait);
            selenium.Click("//a[contains(@href, '/User/Create')]");
            selenium.WaitForPageToLoad(UpgradeSeleniumTester.browserWait);
            selenium.Type("id=Username", "nestor");
            selenium.Type("id=Password", "1");
            selenium.Type("id=Email", "*****@*****.**");
            selenium.Type("id=Name", "nestor");
            selenium.Type("id=UserId", "id_nestor");
            selenium.Type("id=OpenId", "yavora.livejournal.com");
            selenium.Click("//input[@value='Create']");
            selenium.WaitForPageToLoad(UpgradeSeleniumTester.browserWait);
            selenium.Click("//a[contains(@href, '/Account/Logout')]");
            selenium.WaitForPageToLoad(UpgradeSeleniumTester.browserWait);

            selenium.Type("id=loginIdentifier", "yavora.livejournal.com");
            selenium.Click("//div[@id='logindisplay']/form[1]/input[2]");
            selenium.WaitForPageToLoad(UpgradeSeleniumTester.browserWait);

            if (!selenium.IsElementPresent("//a[contains(@href, '/Account/Index')]"))
            {
                selenium.Type("id=login_user", "yavora");
                selenium.Type("id=login_password", "nestor1");
                selenium.Click("//input[@id='loginlj_submit']");
                selenium.WaitForPageToLoad(UpgradeSeleniumTester.browserWait);
                if (selenium.GetLocation().Contains("http://www.livejournal.com"))
                {
                    selenium.Click("//input[@name='yes:once']");
                    selenium.WaitForPageToLoad(UpgradeSeleniumTester.browserWait);
                }
            }

            Assert.IsTrue(selenium.IsElementPresent("//a[contains(@href, '/Account/Index')]"));
        }
        ///<summary>
        /// This method Clicks on the NRF links and validates the URl opened in the new browser
        /// <example>ValidatePopupsofNFR(MyBrowser, "xPath", "Ladbrokes LBR", "https://www.gibraltar.gov.gi/remotegambling");
        public void ValidatePopupsofNFR(ISelenium browser, string xPath, string newWindowTitle, string expURL)
        {
            try
            {
                browser.Click(xPath);
                HGframeworkCommonObj.PageSync(browser);
                HGframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.alertContainer, "5000");
                Thread.Sleep(1000);
                Assert.IsTrue(browser.IsElementPresent(LoginLogoutControls.alertContainer), "Alert container was not displayed on tapping the '" + xPath + "' link");
                Assert.IsTrue(browser.IsTextPresent("You are about to navigate away from the site and any selections you have in the betslip may be lost"), "Warning message[1] is not displayed in the Alert container");
                Assert.IsTrue(browser.IsTextPresent("Do you want to navigate away?"), "Warning message[2] is not displayed in the Alert container");
                browser.Click(LoginLogoutControls.CloseButtonInAlertContainer);
                HGframeworkCommonObj.PageSync(browser);
                Assert.IsFalse(browser.IsVisible(LoginLogoutControls.alertContainer), "Alert container failed to close on tapping the Cancel button");

                browser.Click(xPath);
                HGframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.alertContainer, "5000");
                Thread.Sleep(1000);
                Assert.IsTrue(browser.IsElementPresent(LoginLogoutControls.alertContainer), "Alert container was not displayed on tapping the '" + xPath + "' link");
                browser.Click(LoginLogoutControls.ContinueButtonInAlertContainer);
                HGframeworkCommonObj.PageSync(browser);
                Thread.Sleep(2000);
                HGFcommonObj.SwitchWindow(browser, newWindowTitle);

                string actUrl = browser.GetLocation();
                // url = driver.Url;
                browser.Close();
                browser.SelectWindow("null");
                Thread.Sleep(1000);

                if (actUrl.ToLower().Trim() != expURL.ToLower().Trim())
                {
                    Console.WriteLine("Mismatch in URL's. Actual '" + actUrl + "',  Expected '" + expURL + "'.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Function 'ValidatePopupsofNFR' - Failed");
                Console.WriteLine(ex.Message);
                Fail(ex.Message);
            }
        }
Ejemplo n.º 8
0
        public void CreateUserSuccess()
        {
            var guid = Guid.NewGuid();
            var name = guid.ToString().Replace('-', '_').Substring(0, 12);

            selenium.Click("//a[contains(@href, '/User/Index')]");
            selenium.WaitForPageToLoad("30000");
            selenium.Click("//a[contains(@href, '/User/Create')]");
            selenium.WaitForPageToLoad("30000");
            selenium.Type("id=Username", "un_" + name);
            selenium.Type("id=Password", "1");
            selenium.Type("id=Email", "*****@*****.**");
            selenium.Type("id=Name", "name");
            selenium.Type("id=UserId", "id_" + name);
            selenium.Click("css=input[type=\"submit\"]");
            selenium.WaitForPageToLoad("30000");
            Assert.IsTrue(selenium.GetLocation().EndsWith("/User/Index"));
        }
        ///<summary>
        /// This method verifies the all the policies on Home page 
        /// <example>VerifyPolicies(MyBrowser)</example>  
        public void VerifyPolicies(ISelenium browser, string[] Policies, string[] URLs)
        {
            try
            {
                string url, xPath;
                for (int i = 0; i < Policies.Length; i++)
                {
                    HGframeworkCommonObj.PageSync(browser);
                    xPath = "//a[starts-with(@class, 'bxc tac sec-button small footer') and contains(text(), '" + Policies[i] + "')]";

                    Assert.IsTrue(browser.IsElementPresent(xPath), Policies[i] + " button not found");
                    browser.Click(xPath);
                    HGframeworkCommonObj.PageSync(browser);
                    HGframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.alertContainer, "5000");
                    Thread.Sleep(1000);
                    Assert.IsTrue(browser.IsElementPresent(LoginLogoutControls.alertContainer), "Alert container was not displayed on tapping the '" + Policies[i] + "' link");
                    Assert.IsTrue(browser.IsTextPresent("You are about to navigate away from the site and any selections you have in the betslip may be lost"), "Warning message[1] is not displayed in the Alert container");
                    Assert.IsTrue(browser.IsTextPresent("Do you want to navigate away?"), "Warning message[2] is not displayed in the Alert container");
                    browser.Click(LoginLogoutControls.CloseButtonInAlertContainer);
                    HGframeworkCommonObj.PageSync(browser);
                    Assert.IsFalse(browser.IsVisible(LoginLogoutControls.alertContainer), "Alert container failed to close on tapping the Cancel button");

                    browser.Click(xPath);
                    HGframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.alertContainer, "5000");
                    Thread.Sleep(1000);
                    Assert.IsTrue(browser.IsElementPresent(LoginLogoutControls.alertContainer), "Alert container was not displayed on tapping the '" + Policies[i] + "' link");
                    browser.Click(LoginLogoutControls.ContinueButtonInAlertContainer);
                    HGframeworkCommonObj.PageSync(browser);
                    Thread.Sleep(2000);

                    //Title is different for Desktop policy
                    if (Policies[i] == "Desktop")
                    {
                        HGFcommonObj.SwitchWindow(browser, "Ladbrokes Mobile");
                    }
                    else
                    {
                        HGFcommonObj.SwitchWindow(browser, "LBR Customer KB");
                    }

                    url = browser.GetLocation();
                    // url = driver.Url;
                    browser.Close();
                    browser.SelectWindow("null");
                    Thread.Sleep(1000);

                    if (url.ToLower().Trim() == URLs[i].ToLower().Trim())
                    {
                        Console.WriteLine("'" + Policies[i] + "' validated successfully");
                    }
                    else
                    {
                        Console.WriteLine("Failed to validate the '" + Policies[i] + "'");
                        Fail("Mismatch in Actual and Expected URLs");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Function 'VerifyPolicies' - Failed");
                Console.WriteLine(ex.Message);
                Fail(ex.Message);
            }
        }