Пример #1
0
        public void TestAlert_using_Helper()
        {
            //Javascript executor example

            NavigationHelper.NavigateToUrl("https://www.w3schools.com/js/js_popup.asp");
            ButtonHelper.ClickButton(By.CssSelector("#main>div:nth-of-type(4)>a"));
            BrowserHelper.SwitchToWindow(1);
            ObjectRepository.Driver.SwitchTo().Frame(ObjectRepository.Driver.FindElement(By.CssSelector("#iframeResult")));//switches to frame
            ButtonHelper.ClickButton(By.CssSelector("button[onclick = 'myFunction()']"));
            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"));

            JavaScriptExecutor.ExecuteScript("document.getElementById('textareaCode').setAttribute('style','display: inline;')");
            //if wewant to enterdata in the feild
            JavaScriptExecutor.ExecuteScript("document.getElementById('textareaCode').value = 'new data'");
            // for clicking ------JavaScriptExecutor.ExecuteScript("document.getElementById('hghgjghgjgjgjgj').click()");


            // TextboxHelper.ClearTextBody(By.XPath("//*[@id='textareawrapper']/div/div[6]/div[1]/div/div/div/div[5]"));
            //TextboxHelper.ClearTextBody(By.Id("textareacontainer"));
            // TextboxHelper.ClearTextBody(By.XPath("//*[@id='textareawrapper']/div/div[6]/div[1]/div/div/div"));
            //TextboxHelper.ClearTextBody(By.XPath("//*[@id='textareawrapper']/div/div[1]"));
            // TextboxHelper.ClearTextBody(By.XPath("//*[@id='textareawrapper']/div/div[6]/div[1]/div/div"));
            //Thread.Sleep(200);
            //TextboxHelper.ClearTextBody(By.XPath("//*[@id='textareawrapper']/div/div[6]/div[1]"));
            TextboxHelper.ClearTextBody(By.CssSelector("#textareaCode"));
            TextboxHelper.TypeInTextbox(By.CssSelector("#textareaCode"), text);
        }
Пример #2
0
 public void SearchandReturn(string depart, int value1)
 {
     Flying_from_txtbox.Clear();
     TextboxHelper.ClearTextBody(Flying_from_txtbox);
     Flying_from_txtbox.SendKeys(depart);
     //          ComboboxHelper.SelectElement(Depart_date, value1);
     ComboboxHelper.SelectElement(Depart_date_cmb, value1);
 }
Пример #3
0
        public void SearchandReturn(string depart, string value1)
        {
            TextboxHelper.ClearTextBody(Flying_from); ///>>>not clearing the text box
            ObjectRepository.Driver.FindElement(Flying_from).SendKeys(depart);
            ComboboxHelper.SelectElement(Depart_date, value1);

            //// SelectElement select = new SelectElement(Depart);
            ////select.SelectByIndex(2);
            ////select.SelectByValue("el-GR"); //this works only when the value attribute is populated in the html
            ////select.SelectByText("English (United States)");
            ////Console.WriteLine("Selected value : {0}", select.SelectedOption.Text);
            ////IList<IWebElement> list = select.Options;

            //ObjectRepository.Driver.FindElement(Deprt_new).SendKeys("gh");
            //ObjectRepository.Driver.FindElement(BackTo).Click();
        }
Пример #4
0
        public void TestAlert()
        {
            //giving error in cleartextpart
            NavigationHelper.NavigateToUrl("https://www.w3schools.com/js/js_popup.asp");
            ButtonHelper.ClickButton(By.CssSelector("#main>div:nth-of-type(4)>a"));
            BrowserHelper.SwitchToWindow(1);
            ObjectRepository.Driver.SwitchTo().Frame(ObjectRepository.Driver.FindElement(By.CssSelector("#iframeResult")));//switches to frame
            ButtonHelper.ClickButton(By.CssSelector("button[onclick = 'myFunction()']"));
            IAlert alert = ObjectRepository.Driver.SwitchTo().Alert();
            var    text  = alert.Text;

            alert.Accept();
            ObjectRepository.Driver.SwitchTo().DefaultContent();
            TextboxHelper.ClearTextBody(By.Id("textareaCode"));
            TextboxHelper.TypeInTextbox(By.CssSelector("#textareaCode"), text);
        }