Esempio n. 1
0
        public void PerformActions(string keyword, string locatorType, string locatorValue, params string[] parameters)
        {
            switch (keyword)
            {
            case "Click":
                ButtonHelper.ClickOnButton(GetElementLocator(locatorType, locatorValue));
                break;

            case "SendKeys":
            {
                TextBoxHelper.ClearTextbox(GetElementLocator(locatorType, locatorValue));
                TextBoxHelper.TypeInTextbox(GetElementLocator(locatorType, locatorValue), parameters[0]);
            }
            break;

            case "Navigate":
                NavigationHelper.NavigationToURL(parameters[0]);
                break;

            case "Select":
                DropdownListHelper.SelectElement(GetElementLocator(locatorType, locatorValue), parameters[0]);
                break;

            case "WaitForEle":
                GenericHelpers.WaitForElementInPage(GetElementLocator(locatorType, locatorValue),
                                                    TimeSpan.FromSeconds(60));
                break;

            default:
                throw new NoSuchKeywordException("No such keyword found" + keyword);
            }
        }
Esempio n. 2
0
            public void CheckDropDownList()
            {
                NavigationHelper.NavigationToURL(ObjectRepository.Config.GetWebsite());
                LinkHelper.ClickLink(By.LinkText("File a Bug"));
                Thread.Sleep(100);

                TextBoxHelper.ClearTextbox(By.Id("Bugzilla_login"));
                TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_login"), ObjectRepository.Config.GetUsername());

                TextBoxHelper.ClearTextbox(By.Id("Bugzilla_password"));
                TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_password"), ObjectRepository.Config.GetPassword());

                ButtonHelper.ClickOnButton(By.Id("log_in"));

                DropdownListHelper.SelectElement(By.Id("bug_severity"), 2);

                DropdownListHelper.SelectElement(By.Id("bug_severity"), "minor");

                IList <string> getAllOptions = DropdownListHelper.GetAllItems(By.Id("bug_severity"));

                foreach (string var in getAllOptions)
                {
                    Console.WriteLine(var);
                }
            }
Esempio n. 3
0
        public void CheckRadioButton()
        {
            NavigationHelper.NavigationToURL(ObjectRepository.Config.GetWebsite());
            LinkHelper.ClickLink(By.LinkText("File a Bug"));
            Thread.Sleep(100);

            TextBoxHelper.ClearTextbox(By.Id("Bugzilla_login"));
            TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_login"), ObjectRepository.Config.GetUsername());

            TextBoxHelper.ClearTextbox(By.Id("Bugzilla_password"));
            TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_password"), ObjectRepository.Config.GetPassword());

            ButtonHelper.ClickOnButton(By.Id("log_in"));

            Thread.Sleep(100);

            LinkHelper.ClickLink(By.XPath("//div[@id='header']/ul[1]/li[9]/a"));
            LinkHelper.ClickLink(By.LinkText("Parameters"));
            Thread.Sleep(100);
            Console.WriteLine("Radio button status: {0}", RadioButtonHelper.IsRadioButtonChecked(By.Id("ssl_redirect-on")));

            RadioButtonHelper.CheckedRadioButton(By.Id("ssl_redirect-on"));
            Console.WriteLine("Radio button status: {0}", RadioButtonHelper.IsRadioButtonChecked(By.Id("ssl_redirect-on")));
            Console.WriteLine(GenericHelpers.GetElement(By.XPath("//div[@id='header']/ul[1]/li[11]/a")).Text);
            LinkHelper.ClickLink(By.XPath("//div[@id='header']/ul[1]/li[11]/a"));
        }
        public void TestDefaultWait()
        {
            NavigationHelper.NavigationToURL(ObjectRepository.Config.GetWebsite());
            LinkHelper.ClickLink(By.LinkText("File a Bug"));

            TextBoxHelper.ClearTextbox(By.Id("Bugzilla_login"));
            TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_login"), ObjectRepository.Config.GetUsername());

            TextBoxHelper.ClearTextbox(By.Id("Bugzilla_password"));
            TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_password"), ObjectRepository.Config.GetPassword());

            ButtonHelper.ClickOnButton(By.Id("log_in"));

            ObjectRepository.Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1);

            GenericHelpers.WaitForElement(By.Id("bug_severity"), TimeSpan.FromSeconds(50));
            IWebElement   ele    = GenericHelpers.WaitForElementInPage(By.Id("bug_severity"), TimeSpan.FromSeconds(50));
            SelectElement select = new SelectElement(ele);

            select.SelectByText("major");

            //DefaultWait<IWebElement> wait = new DefaultWait<IWebElement>(ObjectRepository.Driver.FindElement(By.Id("bug_severity")));
            //wait.PollingInterval = TimeSpan.FromMilliseconds(200);
            //wait.Timeout = TimeSpan.FromSeconds(50);
            //wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(ElementNotVisibleException));
            //Console.WriteLine($"After wait: {wait.Until(WaitForValueChange())}");
        }
Esempio n. 5
0
 public void TestActions()
 {
     //NavigationHelper.NavigationToURL("localhost:5001/enter_bug.cgi");
     ButtonHelper.ClickOnButton(By.LinkText("Open a New Account"));
     BrowserHelper.GoBack();
     BrowserHelper.GoForward();
     BrowserHelper.RefreshPage();
 }
Esempio n. 6
0
 public void Logout()
 {
     if (GenericHelpers.IsElenmentPresent(By.XPath("//div[@id='header']/descendant::li[position()=11]/a")))
     {
         ButtonHelper.ClickOnButton(By.XPath("//div[@id='header']/descendant::li[position()=11]/a"));
     }
     GenericHelpers.WaitForElementInPage(By.Id("welcome"), TimeSpan.FromSeconds(30));
 }
Esempio n. 7
0
 public void TestConfirmPopup()
 {
     NavigationHelper.NavigationToURL("https://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm");
     ObjectRepository.Driver.SwitchTo().Frame(ObjectRepository.Driver.FindElement(By.Id("iframeResult")));
     ButtonHelper.ClickOnButton(By.XPath("//button[text()='Try it']"));
     JavaScriptPopupHelper.ClickOKonPopup();
     ButtonHelper.ClickOnButton(By.XPath("//button[text()='Try it']"));
     JavaScriptPopupHelper.ClickCancelOnPopup();
 }
        public void TestExpCondition()
        {
            NavigationHelper.NavigationToURL("https://www.udemy.com/");
            ObjectRepository.Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1);
            WebDriverWait wait = new WebDriverWait(ObjectRepository.Driver, TimeSpan.FromSeconds(50));

            wait.PollingInterval = TimeSpan.FromMilliseconds(250);
            wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(ElementNotVisibleException));
            wait.Until(ExpectedConditions.ElementExists(By.Id("search-field-home"))).SendKeys("HTML");
            ButtonHelper.ClickOnButton(By.XPath("//button[@type='submit']"));
        }
        public void TestJavaScripts()
        {
            NavigationHelper.NavigationToURL(ObjectRepository.Config.GetWebsite());
            ButtonHelper.ClickOnButton(By.LinkText("File a Bug"));
            IJavaScriptExecutor executor = (IJavaScriptExecutor)(ObjectRepository.Driver);

            executor.ExecuteScript("document.getElementById('Bugzilla_login').value='*****@*****.**'");
            executor.ExecuteScript("document.getElementById('Bugzilla_password').value='123456'");
            executor.ExecuteScript("document.getElementById('log_in').click()");
            Thread.Sleep(1000);
        }
        public void TestDynamicWait()
        {
            NavigationHelper.NavigationToURL("https://www.udemy.com/");
            ObjectRepository.Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1);
            WebDriverWait wait = new WebDriverWait(ObjectRepository.Driver, TimeSpan.FromSeconds(50));

            wait.PollingInterval = TimeSpan.FromMilliseconds(250);
            wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(ElementNotVisibleException));
            wait.Until(WaitForElement()).SendKeys("Health");
            ButtonHelper.ClickOnButton(By.CssSelector(".notice-streamer .input-group-btn .btn-link"));
            wait.Until(WaitForLastElement()).Click();
            Console.WriteLine(wait.Until(WaitForPageTitle()));
        }
 public void TestMultipleBrowser()
 {
     NavigationHelper.NavigationToURL("https://www.w3schools.com/js/js_popup.asp");
     ButtonHelper.ClickOnButton(By.XPath("//div[@id='main']/descendant::a[position()=3]"));
     BrowserHelper.SwitchToWindow(0);
     ButtonHelper.ClickOnButton(By.XPath("//div[@id='main']/descendant::a[position()=3]"));
     BrowserHelper.SwitchToWindow(1);
     ButtonHelper.ClickOnButton(By.XPath("//div[@class='w3-bar']/descendant::button"));
     //ButtonHelper.ClickOnButton(By.XPath("//div[@id='main']/descendant::a[position()=2]"));
     //ObjectRepository.Driver.Close();
     //BrowserHelper.SwitchToWindow(0);
     //ObjectRepository.Driver.Quit();
     BrowserHelper.SwitchToParentWindow();
 }
        public void TestFrame()
        {
            NavigationHelper.NavigationToURL("https://www.w3schools.com/js/js_popup.asp");
            ButtonHelper.ClickOnButton(By.XPath("//div[@id='main']/descendant::a[position()=3]"));
            BrowserHelper.SwitchToWindow(1);
            //switch to iframe to work on Iframe
            ObjectRepository.Driver.SwitchTo().Frame(ObjectRepository.Driver.FindElement(By.Id("iframeResult")));
            ButtonHelper.ClickOnButton(By.XPath("//button[text()='Try it']"));
            IAlert alert = ObjectRepository.Driver.SwitchTo().Alert();

            alert.Accept();

            //switch to default data in the page
            ObjectRepository.Driver.SwitchTo().DefaultContent();
            ButtonHelper.ClickOnButton(By.XPath("//div[@class='w3-bar']/descendant::button"));
        }
Esempio n. 13
0
        public void TestPromp()
        {
            NavigationHelper.NavigationToURL("https://www.w3schools.com/js/tryit.asp?filename=tryjs_prompt");
            ObjectRepository.Driver.SwitchTo().Frame(ObjectRepository.Driver.FindElement(By.Id("iframeResult")));
            ButtonHelper.ClickOnButton(By.XPath("//button[text()='Try it']"));
            var popupText = JavaScriptPopupHelper.GetPopupText();

            //IAlert promp = ObjectRepository.Driver.SwitchTo().Alert();
            //promp.SendKeys("Thao");
            //promp.Accept();
            JavaScriptPopupHelper.SendKeys(popupText);
            JavaScriptPopupHelper.ClickOKonPopup();

            //ButtonHelper.ClickOnButton(By.XPath("//button[text()='Try it']"));
            //promp = ObjectRepository.Driver.SwitchTo().Alert();
            //promp.SendKeys("Thao123");
            //promp.Dismiss();
        }
        public void MultiElements()
        {
            NavigationHelper.NavigationToURL(ObjectRepository.Config.GetWebsite());
            LinkHelper.ClickLink(By.LinkText("File a Bug"));
            Thread.Sleep(100);

            TextBoxHelper.ClearTextbox(By.Id("Bugzilla_login"));
            TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_login"), ObjectRepository.Config.GetUsername());

            TextBoxHelper.ClearTextbox(By.Id("Bugzilla_password"));
            TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_password"), ObjectRepository.Config.GetPassword());

            ButtonHelper.ClickOnButton(By.Id("log_in"));

            Thread.Sleep(100);

            ReadOnlyCollection <IWebElement> elements = ObjectRepository.Driver.FindElements(By.LinkText("Administration"));

            Console.WriteLine(elements[0].Text.ToString());
            Console.WriteLine(elements[1].Text.ToString());
        }
Esempio n. 15
0
        public void TestAlert()
        {
            //NavigationHelper.NavigationToURL("https://www.w3schools.com/js/js_popup.asp");
            //ButtonHelper.ClickOnButton(By.XPath("//div[@id='main']/descendant::a[position()=3]"));
            //BrowserHelper.SwitchToWindow(1);
            //switch to iframe to work on Iframe
            NavigationHelper.NavigationToURL("https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert");
            ObjectRepository.Driver.SwitchTo().Frame(ObjectRepository.Driver.FindElement(By.Id("iframeResult")));
            ButtonHelper.ClickOnButton(By.XPath("//button[text()='Try it']"));
            if (JavaScriptPopupHelper.IsPopupPresent())
            {
                var text = JavaScriptPopupHelper.GetPopupText();
                JavaScriptPopupHelper.ClickOKonPopup();
                ObjectRepository.Driver.SwitchTo().DefaultContent();
                // Add this line before the line of code , where you are trying to clear the text area
                IWebElement textarea = ObjectRepository.Driver.FindElement(By.Id("textareaCode"));
                ExecuteScript("document.getElementById('textareaCode').setAttribute('style','display: inline;')");

                TextBoxHelper.ClearTextbox(By.Id("textareaCode"));
                TextBoxHelper.TypeInTextbox(By.Id("textareaCode"), text);
            }
        }
Esempio n. 16
0
        public void ClickLoginButton()
        {
            NavigationHelper.NavigationToURL(ObjectRepository.Config.GetWebsite());
            LinkHelper.ClickLink(By.LinkText("File a Bug"));
            Thread.Sleep(100);

            TextBoxHelper.ClearTextbox(By.Id("Bugzilla_login"));
            TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_login"), ObjectRepository.Config.GetUsername());

            TextBoxHelper.ClearTextbox(By.Id("Bugzilla_password"));
            TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_password"), ObjectRepository.Config.GetPassword());

            Console.WriteLine(CheckboxHelper.IsChecboxChecked(By.Id("Bugzilla_restrictlogin")));
            if (CheckboxHelper.IsChecboxChecked(By.Id("Bugzilla_restrictlogin")))
            {
                CheckboxHelper.CheckedCheckbox(By.Id("Bugzilla_restrictlogin"));
            }
            Console.WriteLine(CheckboxHelper.IsChecboxChecked(By.Id("Bugzilla_restrictlogin")));

            Console.WriteLine(ButtonHelper.GetButtonText(By.Id("log_in")));
            Console.WriteLine(ButtonHelper.IsButtonEnabled(By.Id("log_in")));
            ButtonHelper.ClickOnButton(By.Id("log_in"));
        }
 public void WhenUserClickOnTheCreateSchedule()
 {
     ButtonHelper.ClickOnButton(By.XPath("//button//span[text()='Create Schedule']"));
 }