Пример #1
0
        public void promptAlert()
        {
            //This line will create alert instance

            IAlert alert = driver.SwitchTo().Alert();

            //It sets the text to alert box

            alert.SendKeys("selenium");
            alert.SendKeys(Keys.Tab);
            //This line will accept the alert
            alert.Accept();
        }
Пример #2
0
 public static void AlertDataEnter(RemoteWebDriver _driver, string value)
 {
     try
     {
         IAlert alert = _driver.SwitchTo().Alert();
         //_driver.SwitchTo().
         alert.SendKeys(value);
         logger.Debug("Entered text " + value + " in alert textbox successfully");
         alert.SendKeys(Keys.Tab);
     }
     catch (Exception e)
     {
         logger.Error("Enter text failed for alert text box with exception - " + e.Message);
     }
 }
Пример #3
0
        public void AlertaEscrever(String valor)
        {
            IAlert alert = GetDriver().SwitchTo().Alert();

            alert.SendKeys(valor);
            alert.Accept();
        }
Пример #4
0
        public static void WriteIntoAlert(IWebDriver webDriver, string _text)
        {
            WebDriverWait wait  = new WebDriverWait(webDriver, TimeSpan.FromSeconds(30));
            IAlert        alert = wait.Until(x => webDriver.SwitchTo().Alert());

            alert.SendKeys(_text);
        }
        public void Login(string userName, string password)
        {
            IAlert alert = WebDriverWrapper.WebDriver.SwitchTo().Alert();

            alert.SendKeys(userName + Keys.Tab.ToString() + password);
            alert.Accept();
        }
Пример #6
0
        /// <summary>
        /// Method to validate paypal transaction
        /// </summary>
        /// <param name="emailId">EMail id</param>
        /// <param name="password">Password</param>
        public void validatePaypalTransaction(string emailId, string password)
        {
            try
            {
                driver.sleepTime(10000);
                if (driver.IsElementPresent(framePaypalLogin))
                {
                    driver.SwitchToFrameByLocator(framePaypalLogin);
                    driver.SendKeysToElement(txtEmail, emailId, "Email");
                    driver.SendKeysToElement(txtPassword, password, "Email");
                    driver.ClickElement(btnLogin, "Login");
                    driver.SwitchToDefaultFrame();
                    driver.sleepTime(10000);
                }

                driver.WaitForPageLoad(TimeSpan.FromSeconds(30));
                driver.WaitElementExistsAndVisible(btnContinue);
                driver.CheckElementExists(lnkCancelLink, "Cancel");
                driver.ClickElement(btnContinue, "Continue");

                if (driver.isAlertPresent())
                {
                    IAlert devAlert = driver.SwitchTo().Alert();
                    devAlert.SendKeys("testdev");
                    devAlert.Accept();
                }
                driver.WaitForPageLoad(TimeSpan.FromSeconds(60));
            }
            catch (Exception ex)
            {
                this.TESTREPORT.LogFailure("validatePaypalTransaction", "Failed to validate Paypal transaction", EngineSetup.GetScreenShotPath());
            }
        }
Пример #7
0
        public void TestPrompt()
        {
            //Clicking button will show a Prompt Alert asking user to enter
            //value/text with OK and Cancel Button
            IWebElement button = driver.FindElement(By.Id("prompt"));

            button.Click();

            try {
                //Get the Alert
                IAlert alert = driver.SwitchTo().Alert();

                //Enter some value on Prompt by calling sendKeys() method of Alert Class
                alert.SendKeys("Foo");

                //Click OK button, by calling accept() method of Alert Class
                alert.Accept();

                //Verify Page displays message with value entered in Prompt
                IWebElement message = driver.FindElement(By.Id("prompt_demo"));
                Assert.AreEqual("Hello Foo! How are you today?", message.Text);
            } catch (NoAlertPresentException e) {
                Assert.Fail("Alert not found!!");
            }
        }
        public void TestPromptPopup()
        {
            //Get object of the Prompt Popup button

            IWebElement promptPopup_Btn = driver.FindElementByXPath(promptPopup_Xpath);

            //Creating the object of the IJavascriptExecutor

            IJavaScriptExecutor jse = (IJavaScriptExecutor)driver;

            jse.ExecuteScript("arguments[0].click()", promptPopup_Btn);

            //Switch the control of 'Driver' to the alert from the main window

            IAlert promptPopup_Alert = driver.SwitchTo().Alert();

            //The method 'Text' is used to get Text from alert currently

            string text = promptPopup_Alert.Text;

            //Send a part text to the prompt of alert

            promptPopup_Alert.SendKeys("I love automation than any things");

            //Sleep about 3s to look at, but it's not necessary

            Thread.Sleep(3000);

            //the method 'Accept()' is used to accept the alert

            promptPopup_Alert.Accept();
        }
        public void Test()
        {
            IWebDriver driver = new ChromeDriver();

            // Go to website
            driver.Navigate().GoToUrl("http://toolsqa.com/handling-alerts-using-selenium-webdriver/");

            // Scroll down by pixels
            IJavaScriptExecutor js = (IJavaScriptExecutor)driver;

            js.ExecuteScript("window.scrollBy(0,500)");

            // This will produce alert on screen
            driver.FindElement(By.XPath("//*[@id=\"content\"]/p[11]/button")).Click();

            // Switch the control of 'driver' to Alert from main window
            IAlert promptAlert = driver.SwitchTo().Alert();

            // Get the text from the alert
            String alertText = promptAlert.Text;

            Console.WriteLine("This is the text from the alert: {0}.", alertText);

            // '.SendKeys()' to enter the text in to the textbox of the alert
            promptAlert.SendKeys("Accepting the Alert");

            Thread.Sleep(2000);

            // '.Accept()' to accept the alert '(click on the Ok button)'
            promptAlert.Accept();

            // Quit the browser
            driver.Quit();
        }
Пример #10
0
            public void PromptTest()
            {
                IWebDriver driver = new ChromeDriver();

                driver.Url = "http://toolsqa.wpengine.com/handling-alerts-using-selenium-webdriver/";
                driver.Manage().Window.Maximize();

                //This step produce an alert on screen
                IWebElement element = driver.FindElement(By.XPath("//*[@id='content']/p[11]/button"));

                // 'IJavaScriptExecutor' is an 'interface' which is used to run the 'JavaScript code' into the webdriver (Browser)
                ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click()", element);

                // Switch the control of 'driver' to the Alert from main window
                IAlert promptAlert = driver.SwitchTo().Alert();

                // Get the Text of Alert
                String alertText = promptAlert.Text;

                Console.WriteLine("Alert text is " + alertText);

                //'.SendKeys()' to enter the text in to the textbox of alert
                promptAlert.SendKeys("Accepting the alert");

                Thread.Sleep(4000); //This sleep is not necessary, just for demonstration

                // '.Accept()' is used to accept the alert '(click on the Ok button)'
                promptAlert.Accept();
            }
Пример #11
0
        public AlertPage SendKeysToThirdAlert(string text)
        {
            IAlert alert = Driver.SwitchTo().Alert();

            alert.SendKeys(text);
            alert.Accept();
            return(this);
        }
        public static void HandleJsAlertswithSendKey()
        {
            Driver.Instance.FindElement(By.XPath("/html/body/div[2]/div/div/ul/li[3]/button")).Click();
            IAlert alertDialog = Driver.Instance.SwitchTo().Alert();

            alertDialog.SendKeys("test");
            alertDialog.Accept();
        }
Пример #13
0
        public void PromptAlertBox()
        {
            PromptBox.Click();
            IAlert alert = _driver.SwitchTo().Alert();

            alert.SendKeys("Some text");
            alert.Accept();
        }
Пример #14
0
        public void WhenentertextAndClickCancel(string texttoinput)
        {
            var driver = _webDriver.Current;

            alertsPage.btnJSPrompt.Click();
            alert = driver.SwitchTo().Alert();
            alert.SendKeys(texttoinput);
            alert.Dismiss();
        }
Пример #15
0
        public void SetTextInAlert(string text)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            wait.Until(ExpectedConditions.AlertIsPresent());
            IAlert alert = driver.SwitchTo().Alert();

            alert.SendKeys(text);
            alert.Accept();
        }
        internal JsPromtWindow VerifyJSPromtFunctionality(IWebDriver driver)
        {
            ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click()", JSPromtButton);
            IAlert promptAlert = driver.SwitchTo().Alert();
            String alertText   = promptAlert.Text;

            promptAlert.SendKeys("Test");
            Thread.Sleep(4000);
            promptAlert.Accept();
            return(new JsPromtWindow(Driver));
        }
Пример #17
0
 public void SendKeys(string s)
 {
     try
     {
         alert.SendKeys(s);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Пример #18
0
        public string ClickForPrompt(string message)
        {
            JSPrompt.Click();
            WebDriverWait wait  = new WebDriverWait(_driver, TimeSpan.FromSeconds(5));
            IAlert        alert = wait.Until(ExpectedConditions.AlertIsPresent());
            string        text  = alert.Text;

            alert.SendKeys(message);
            alert.Accept();
            return(text);
        }
Пример #19
0
        public _ EnterAs(string name)
        {
            IAlert alert = Driver.SwitchTo().Alert();

            alert.SendKeys(name);     // Note that SendKeys doesn't work in Chrome for a long time. Works in Firefox for example.
            alert.Accept();

            Driver.SwitchTo().DefaultContent();

            return(Owner);
        }
        public _ EnterAs(string name)
        {
            IAlert alert = Driver.SwitchTo().Alert();

            alert.SendKeys(name);
            alert.Accept();

            Driver.SwitchTo().DefaultContent();

            return(Owner);
        }
        public void jsAlertTest()
        {
            driver.Navigate().GoToUrl("https://the-internet.herokuapp.com/javascript_alerts");
            driver.FindElement(By.XPath("//div[@id='content']/div/ul/li[3]/button")).Click();

            IAlert alert = driver.SwitchTo().Alert();

            alert.SendKeys("Hello ! DS. Click to Ok or cancle");
            Thread.Sleep(3000);

            alert.Accept();
        }
Пример #22
0
        public void PromptInsertValue()
        {
            alertPO.JsPromptBtn.Click();

            IAlert jsAlertPopup = driver.SwitchTo().Alert();

            jsAlertPopup.SendKeys("Testing Alerts!");

            jsAlertPopup.Accept();

            Assert.Equal("You entered: Testing Alerts!", alertPO.ResultText.Text);
        }
Пример #23
0
        public void AlertEnterText(string text)
        {
            this.SetActiveAlert();
            ActiveAlert.SendKeys(text);

            try
            {
                // just do it - attempting to get behaviors between browsers to match
                ActiveAlert.Accept();
            }
            catch (Exception) { }
        }
Пример #24
0
 public static void TypeText(String text)
 {
     if (!IsAlertPresent())
     {
         return;
     }
     else
     {
         IAlert alt = ObjectRepository.Driver.SwitchTo().Alert();
         alt.SendKeys(text);
     }
 }
Пример #25
0
        public void PromptAlert()
        {
            _driver.FindElement(By.XPath("html/body/div[1]/div[5]/div[2]/div/div/p[11]/button")).Click();
            IAlert promptAlert = _driver.SwitchTo().Alert();

            string alertText = promptAlert.Text;

            Console.WriteLine("Alert Text is " + alertText);

            promptAlert.SendKeys("Accept the Alert");
            Thread.Sleep(4000);
            promptAlert.Accept();
        }
Пример #26
0
        /// <summary>
        /// ManualLogin
        /// </summary>
        /// <param name="driver"></param>
        public static void ManualLogin(IWebDriver driver)
        {
            Thread.Sleep(1000);
            IAlert alert = driver.SwitchTo().Alert();

            alert.SendKeys(System.Configuration.ConfigurationManager.AppSettings["AdsUser"]);
            Thread.Sleep(1000);
            SendKeys.SendWait("{TAB}");
            Thread.Sleep(2000);
            SendKeys.SendWait(System.Configuration.ConfigurationManager.AppSettings["AdsPassword"]);
            SendKeys.SendWait("{Enter}");
            Thread.Sleep(2000);
        }
Пример #27
0
        public void SwitchToPrompt()
        {
            IWebDriver driver = new ChromeDriver();

            driver.Url = "http://uitestpractice.com/Students/Switchto";
            driver.Manage().Window.Maximize();
            driver.FindElement(By.Id("prompt")).Click();

            IAlert alert = driver.SwitchTo().Alert();

            alert.SendKeys("Hello World");

            driver.Quit();
        }
Пример #28
0
        public void ShouldAllowAUserToSetTheValueOfAPrompt()
        {
            driver.Url = CreatePromptPage(null);

            driver.FindElement(By.Id("prompt")).Click();

            IAlert alert = WaitFor <IAlert>(AlertToBePresent, "No alert found");

            alert.SendKeys("cheese");
            alert.Accept();

            string result = driver.FindElement(By.Id("text")).Text;

            Assert.AreEqual("cheese", result);
        }
Пример #29
0
        public async Task ShouldThrowArgumentNullExceptionWhenKeysNull()
        {
            await driver.GoToUrl(CreateAlertPage("cheese"));

            await driver.FindElement(By.Id("alert")).Click();

            IAlert alert = await WaitFor(AlertToBePresent(), "No alert found");

            try {
                //Assert.That(async () => await alert.SendKeys(null), Throws.ArgumentNullException);
                await AssertEx.ThrowsAsync <ArgumentNullException>(async() => await alert.SendKeys(null));
            } finally {
                await alert.Accept();
            }
        }
Пример #30
0
        public void ShouldAllowAUserToSetTheValueOfAPrompt()
        {
            driver.Url = alertsPage;

            driver.FindElement(By.Id("prompt")).Click();

            IAlert alert = driver.SwitchTo().Alert();

            alert.SendKeys("cheese");
            alert.Accept();

            string result = driver.FindElement(By.Id("text")).Text;

            Assert.AreEqual("cheese", result);
        }