public void TestPrompt() { NavigationHelper.NavigateToUrl("http://www.w3schools.com/js/tryit.asp?filename=tryjs_prompt"); BrowserHelper.SwitchToFrame(By.Id("iframeResult")); ButtonHelper.ClickButton(By.XPath("//button[text()='Try it']")); var text = JavaScriptPopHelper.GetPopUpText(); JavaScriptPopHelper.SendKeys(text); JavaScriptPopHelper.ClickOkOnPopup(); BrowserHelper.RefreshPage(); BrowserHelper.SwitchToFrame(By.Id("iframeResult")); ButtonHelper.ClickButton(By.XPath("//button[text()='Try it']")); text = JavaScriptPopHelper.GetPopUpText(); JavaScriptPopHelper.SendKeys(text + "abc"); JavaScriptPopHelper.ClickCancelOnPopup(); ObjectRepository.Driver.SwitchTo().DefaultContent(); GenericHelper.WaitForWebElement(By.Id("textareaCode"), TimeSpan.FromSeconds(60)); //TextBoxHelper.ClearTextBox(By.Id("textareaCode")); //TextBoxHelper.TypeInTextBox(By.Id("textareaCode"), text); //IAlert prompt = ObjectRepository.Driver.SwitchTo().Alert(); //prompt.SendKeys("This is automation"); //prompt.Accept(); // ButtonHelper.ClickButton(By.XPath("//button[text()='Try it']")); //prompt = ObjectRepository.Driver.SwitchTo().Alert(); //prompt.SendKeys("This is automation"); //prompt.Dismiss(); Logger.Info("Test Prompt Complete"); }
public void TestPrompt() { NavigationHelper.NavigateToUrl("http://www.w3schools.com/js/tryit.asp?filename=tryjs_prompt"); BrowserHelper.SwitchToFrame(By.Id("iframeResult")); ButtonHelper.ClickButton(By.XPath("//button[text()='Try it']")); var text = JavaScriptPopHelper.GetPopUpText(); JavaScriptPopHelper.SendKeys(text); JavaScriptPopHelper.ClickOkOnPopup(); BrowserHelper.RefreshPage(); BrowserHelper.SwitchToFrame(By.Id("iframeResult")); ButtonHelper.ClickButton(By.XPath("//button[text()='Try it']")); text = JavaScriptPopHelper.GetPopUpText(); JavaScriptPopHelper.SendKeys(text + "abc"); JavaScriptPopHelper.ClickCancelOnPopup(); ObjectRepository.Driver.SwitchTo().DefaultContent(); GenericHelper.WaitForWebElement(By.Id("textareaCode"), TimeSpan.FromSeconds(60)); }