public void Fill(FullElementSelector fullElementSelector, string testId, string testName) { /* credit card number */ Driver.GetWait().Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.XPath("//*[@id='tokenexIframe']"))); Driver.Instance.FindElement(By.Id("pan")).SendKeys(cardNo); // Driver.Instance.SwitchTo().DefaultContent(); Helper.WriteToCSV("Payment Details Page", "Card number filled", true, cardNo, testId, testName); Thread.Sleep(1500); /* name */ Driver.GetWait().Until(ExpectedConditions.ElementExists(By.XPath(fullElementSelector.cardholderNameElement))); var name_ = Driver.Instance.FindElement(By.XPath(fullElementSelector.cardholderNameElement)); name_.SendKeys(cardHolderName); Helper.WriteToCSV("Payment Details Page", "Cardholder name filled", true, null, testId, testName); /* Expiry */ //Driver.GetWait().Until(ExpectedConditions.ElementExists(By.XPath("/html/body/chubb-dbs-app/app-pay/payment-dbs/form/div[1]/div[3]/div[2]/div[1]/mat-form-field/div/div[1]/div/input"))); var expiry = Driver.Instance.FindElement(By.XPath(fullElementSelector.cardExpiryElement)); expiry.SendKeys(expiryDate); Helper.WriteToCSV("Payment Details Page", "Expiry Date filled", true, null, testId, testName); /* cvv */ //Driver.GetWait().Until(ExpectedConditions.ElementExists(By.XPath("/html/body/chubb-dbs-app/app-pay/payment-dbs/form/div[1]/div[3]/div[2]/div[2]/mat-form-field/div/div[1]/div/input"))); var cvv_ = Driver.Instance.FindElement(By.XPath(fullElementSelector.cardCvvElement)); cvv_.SendKeys(cvv); Helper.WriteToCSV("Payment Details Page", "cvv filled", true, null, testId, testName); // }
public void ThenISwitchToIframeWithId(string iframeId) { IWebElement frame = webDriver.FindElement(By.Id(iframeId)); wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(60)); wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.Id(iframeId))); // webDriver.SwitchTo().Frame(frame); }
public static void WaitAndSwitchToFrame(this IWebDriver driver, int timeOutInSecond, By FrameLocator) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeOutInSecond)); WaitForJStoLoad(driver); driver = wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt((FrameLocator))); }
public void DragAndDropQuiz1() { var actions = new Actions(driver); var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5)); wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.Id("ExampleFrame-94"))); //assert "moving out!" var sourceElement = driver.FindElement(By.XPath("//*[@class='square ui-draggable']")); var targetElement = driver.FindElement(By.XPath("//*[@class='squaredotted ui-droppable']")); var drag = actions .ClickAndHold(sourceElement) .MoveToElement(targetElement) .Build(); drag.Perform(); var message = driver.FindElement(By.XPath("//*[@id='info']")); Assert.That(message.Text, Is.EqualTo("moving in!")); var drop = actions .Release(targetElement) .Build(); drop.Perform(); message = driver.FindElement(By.XPath("//*[@id='info']")); Assert.That(message.Text, Is.EqualTo("dropped!")); }
/// <summary> /// Wait for Frame available and switch to it /// </summary> /// <param name="by"></param> public static void WaitForFrameAndSwitchToIt(By by) { try { WebDriverWait wait = new WebDriverWait(DriverInstance.Instance, explicitTimeOutPeriod); wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(by)); LoggerInstance.log.Info("Driver explicitly waits " + explicitTimeOutPeriod + " seconds for iframe to be available and switch to it"); } catch (NoSuchFrameException frameNotPresent) { LoggerInstance.log.Error(frameNotPresent.Message, frameNotPresent); } catch (WebDriverTimeoutException webdriverTimeOut) { LoggerInstance.log.Error(webdriverTimeOut.Message, webdriverTimeOut); } catch (TimeoutException timeOut) { LoggerInstance.log.Error(timeOut.Message, timeOut); } catch (Exception e) { LoggerInstance.log.Error(e.Message, e); } }
public void traverseToContentBodyFrameTableSettings() { IWebElement ele = extWait.Until( ExpectedConditions.ElementExists(By.XPath("//div[contains(@style,'visibility: visible')]//iframe"))); driver.SwitchTo().Frame(ele); extWait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.Name("tableContentFrame"))); }
/// <summary> /// Web driver frame handler to control the frames. /// </summary> /// <param name="testStep">Test step as parameter.</param> /// <returns>Returns true or false.</returns> public static bool WebDriverFrameHandler(TestStep testStep) { try { IWebElement element; var action = Convert.ToString(testStep.TestData[Convert.ToInt32(testStep.TestDataKeyToUse)]); var value = testStep.UiControl.UiControlSearchValue; WebDriverWait wait = new WebDriverWait(WebdriverBrowser.Driver, TimeSpan.FromSeconds(Convert.ToInt32(General.WaitForControlToExistTimeOut))); switch (action.ToUpper()) { case "SWITCHFRAMEBYINDEX": int index = Convert.ToInt32(value); //WaitForControlToExist(testStep); //// Throws WebDriverTimeoutException WebdriverBrowser.Driver.SwitchTo().DefaultContent(); WebdriverBrowser.Driver.SwitchTo().Frame(index); break; case "SWITCHFRAMEBYID": wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(testStep.UiControl.UiControlSearchValue)); //// Throws WebDriverTimeoutException WebdriverBrowser.Driver.SwitchTo().DefaultContent(); WebdriverBrowser.Driver.SwitchTo().Frame(Convert.ToString(value)); break; case "SWITCHFRAMEBYNAME": wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(testStep.UiControl.UiControlSearchValue)); //// Throws WebDriverTimeoutException WebdriverBrowser.Driver.SwitchTo().DefaultContent(); WebdriverBrowser.Driver.SwitchTo().Frame(Convert.ToString(value)); break; case "SWITCHFRAMEBYELEMENT": WaitForControlToExist(testStep); //// Throws WebDriverTimeoutException element = WebdriverBrowser.Driver.FindElement(By.XPath(testStep.UiControl.UiControlSearchValue)); WebdriverBrowser.Driver.SwitchTo().DefaultContent(); WebdriverBrowser.Driver.SwitchTo().Frame(element); break; default: return(false); } Result.PassStepOutandSave(testStep.TestDataKeyToUse, testStep.TestStepNumber, "WebDriverFrameHandler", Entities.Constants.Pass, "Switched to frame \'" + value + "\' using \'" + action + "\'.", testStep.Remarks); return(true); } catch (WebDriverTimeoutException ex) { Result.PassStepOutandSave(testStep.TestDataKeyToUse, testStep.TestStepNumber, "WebDriverFrameHandler", Entities.Constants.Fail, string.Format(Entities.Constants.Messages.WebDriverTimeoutException, ex.Message), testStep.Remarks); LogHelper.ErrorLog(ex, Entities.Constants.ClassName.UiActionsClassName, MethodBase.GetCurrentMethod().Name); return(false); } catch (Exception ex) { Result.PassStepOutandSave(testStep.TestDataKeyToUse, testStep.TestStepNumber, "WebDriverFrameHandler", Entities.Constants.Fail, string.Format(Entities.Constants.Messages.DueToException, ex.Message), testStep.Remarks); LogHelper.ErrorLog(ex, Entities.Constants.ClassName.UiActionsClassName, MethodBase.GetCurrentMethod().Name); return(false); } }
public void waitToLoadAndClickAccept() { var wait = new WebDriverWait(_driver, new TimeSpan(0, 0, 30)); var frame = wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.XPath("//*[@id='consent-bump']/div/div[1]/iframe"))); var acceptButton = wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("introAgreeButton"))); acceptButton.Click(); _driver.SwitchTo().DefaultContent(); }
public void Resizable() { _driver.Navigate().GoToUrl("https://jqueryui.com/resizable/"); _wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.ClassName("demo-frame"))); IWebElement resibleHandle = _driver.FindElement(By.XPath("//*[@class='ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se']")); _action.ClickAndHold(resibleHandle).MoveByOffset(120, 120).Perform(); Assert.IsTrue(_driver.FindElement(By.XPath("//*[@id='resizable' and @style]")).Displayed); }
/// <summary> /// Internal method that does the frame swap</summary> /// <param name="driver">Webdriver</param> /// <param name="frameLocator"> Allow user to locate a frame by what method they choose</param> private static void SwitchToFrame(IWebDriver driver, By frameLocator) { try { var wait = new WebDriverWait(driver, DefaultTimeout); wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(frameLocator)); } catch (NoSuchFrameException nsfe) { throw nsfe; } }
public void DragDropExample1() { _driver.Navigate().GoToUrl("https://jqueryui.com/droppable/"); _wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.ClassName("demo-frame"))); IWebElement targetElement = _driver.FindElement(By.Id("droppable")); IWebElement sourceElement = _driver.FindElement(By.Id("draggable")); _action.DragAndDrop(sourceElement, targetElement).Perform(); Assert.AreEqual("Dropped!", targetElement.Text); }
public void ClickToWorkSpace() { Thread.Sleep(2000); WebDriverWait obj = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); obj.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.Id("_externalPage"))); var selectElementSaveSearch = new SelectElement(ComboboxTemplate); selectElementSaveSearch.SelectByValue("_s1"); Thread.Sleep(0500); driver.FindElement(By.LinkText(ConfigurationHelper.TEST_WORKSPACE_NAME)).Click(); }
public void RunScript() { WebDriverWait OBJ = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); OBJ.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.Id("_externalPage"))); VisibilityOfAllElementsLocatedBy(By.Id("fil_itemListFUI"), 10); IList <IWebElement> all = TableScripts.FindElements(By.TagName("tr")); IList <IWebElement> all1 = all[3].FindElements(By.TagName("td")); IList <IWebElement> all2 = all1[5].FindElements(By.TagName("a")); all2[0].Click(); }
public void TestMethod3() { _driver.Navigate().GoToUrl("http://www.pureexample.com/jquery-ui/basic-droppable.html"); _wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.Id("ExampleFrame-94"))); IWebElement sourceElement = _driver.FindElement(By.XPath(".//*[@class='square ui-draggable']")); IWebElement targetElement = _driver.FindElement(By.XPath(".//*[contains(text(),'Drop here')]")); IWebElement finalText = _driver.FindElement(By.Id("info")); _actions.DragAndDrop(sourceElement, targetElement).Perform(); Assert.AreEqual("dropped!", finalText.Text); }
public void Validatate_WebreportLogoutPage() { try { QAReportsDriver = objbase.Initializedriver(); QAReportsDriver.Navigate().GoToUrl(ConfigurationSettings.AppSettings["QAT"]); QAReportsDriver.Manage().Window.Maximize(); objbase.WaitforPageload(); IWebElement elelnkreport = QAReportsDriver.FindElement(By.Id("btnReports")); IJavaScriptExecutor QAReportexecutor = (IJavaScriptExecutor)QAReportsDriver; QAReportexecutor.ExecuteScript("arguments[0].click();", elelnkreport); objbase.WaitforPageload(); IWebElement tableqareportsmenu = QAReportsDriver.FindElement(By.Id("reportsMenu")); objbase.WaitforPageload(); IWebElement lnkqareports = QAReportsDriver.FindElement(By.LinkText("Hermes Web Reports")); QAReportexecutor.ExecuteScript("arguments[0].click();", lnkqareports); objbase.WaitforPageload(); QAReportsDriver.SwitchTo().Window(QAReportsDriver.WindowHandles.Last()); objbase.WaitforPageRefresh(); // QAReportsDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20); /* objbase.WaitUntilFrameLoadedAndSwitchToIt(By.Name("tabedindex")); * QAReportsDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); * QAReportsDriver.SwitchTo().Frame("tabedindex");*/ QAReportsDriver.FindElement(By.Name("tabedindex")); objbase.WaitForFrameload(); var wdwatfortabbedindex = new WebDriverWait(QAReportsDriver, TimeSpan.FromSeconds(30)); wdwatfortabbedindex.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt("tabedindex")); objbase.WaitForFrameload(); // QAReportsDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); IWebElement eleInvestorFund = QAReportsDriver.FindElement(By.Id("tabid13")); objbase.WaitforPageRefresh(); QAReportexecutor.ExecuteScript("arguments[0].click();", eleInvestorFund); objbase.WaitforPortfolioload(); QAReportsDriver.SwitchTo().DefaultContent(); QAReportsDriver.Quit(); } catch (Exception exlogout) { Console.WriteLine(" Web Logout exception " + exlogout.Message.ToString()); QAReportsDriver.Quit(); } }
/// <summary> /// An expectation for wait and check whether the given frame is available to switch to. If the frame is available it switches the driver to the specified frame. /// </summary> /// <param name="locator">Locator for the web element.</param> /// <param name = "waitType" > Type of wait from <see cref="WaitType"/>.</param> public void WaitAndSwitchToFrame(By locator, WaitType waitType) { try { TimeSpan time = GetWait(waitType); WebDriverWait wait = new WebDriverWait(Driver, time); wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(locator)); } catch (Exception e) { CustomExceptionHandler.CustomException(e, "Timeout exception while waiting for frame: " + locator); } }
public void Resizable() { _driver.Navigate().GoToUrl("http://jqueryui.com/resizable/"); _driver.Manage().Window.Maximize(); _wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.ClassName("demo-frame"))); IWebElement cornerResizable = _driver.FindElement(By.XPath("//*[@class='ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se']")); _actions.ClickAndHold(cornerResizable).MoveByOffset(300, 200).Perform(); Assert.IsTrue(_driver.FindElement(By.XPath("//*[@id='resizable']")).Displayed); TestContext.Out.WriteLine("Matcheables"); }
public static IWebDriver UntilFrameToBeAvailableAndSwitchToIt(string name, IWebDriver driver, TimeSpan timeOut) { WebDriverWait wdWait = new WebDriverWait(driver, timeOut); wdWait.IgnoreExceptionTypes ( typeof(ElementNotVisibleException), typeof(NoSuchElementException), typeof(StaleElementReferenceException) ); return(wdWait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(name))); }
public void switchToIFrame(String idOrNameOfIframe) { try { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(idOrNameOfIframe)); driver.SwitchTo().Frame(idOrNameOfIframe); } catch (OpenQA.Selenium.NoSuchElementException e) { Console.WriteLine("Error: " + e); } }
public void JQueryDragDropQuiz() { _driver.Navigate().GoToUrl("http://www.pureexample.com/jquery-ui/basic-droppable.html"); _wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.Id("ExampleFrame-94"))); var sourceLocator = _driver.FindElement(By.XPath("//*[@class='square ui-draggable']")); var distanationLocator = _driver.FindElement(By.XPath("//*[@class='squaredotted ui-droppable']")); _action.DragAndDrop(sourceLocator, distanationLocator).Perform(); var droppedText = _driver.FindElement(By.Id("info")).Text; Assert.AreEqual("dropped!", droppedText); }
public Boolean SwitchToIframe(By Locator) { try { objBaseTestClass.GetObjWebDriverWait().Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(Locator)); return(true); } catch (Exception e) { Console.WriteLine("Got Exception" + e.Message); return(false); } }
public void DragDropQuiz() { _driver.Navigate().GoToUrl("http://www.pureexample.com/jquery-ui/basic-droppable.html"); _wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.Id("ExampleFrame-94"))); IWebElement dragSource = _driver.FindElement(By.XPath("//*[@class='square ui-draggable']")); IWebElement dropTarget = _driver.FindElement(By.XPath("//*[@class='squaredotted ui-droppable']")); _actions.DragAndDrop(dragSource, dropTarget).Perform(); IWebElement dropText = _driver.FindElement(By.Id("info")); Assert.AreEqual("dropped!", dropText.Text); }
public static bool WaitForFrame(By iframe) { try { GetWaitDriver.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(iframe)); return(true); } catch (Exception ex) { Thread.Sleep(100); } return(false); }
public void DragAndDropTest1() { var actions = new Actions(driver); var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5)); wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.ClassName("demo-frame"))); var sourceElement = driver.FindElement(By.Id("draggable")); var targetElement = driver.FindElement(By.Id("droppable")); actions.DragAndDrop(sourceElement, targetElement).Perform(); Assert.That(targetElement.Text, Is.EqualTo("Dropped!")); }
public void Example1() { var driver = new FirefoxDriver(); var actions = new Actions(driver); var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(6)); driver.Navigate().GoToUrl("http://jqueryui.com/droppable/"); wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.ClassName("demo-frame"))); IWebElement targetElement = driver.FindElement(By.Id("droppable")); IWebElement sourceElement = driver.FindElement(By.Id("draggable")); actions.DragAndDrop(sourceElement, targetElement).Perform(); Assert.AreEqual("Dropped!", targetElement.Text); }
public void SwitchToIframe(int index, By childLocator) { if (childLocator != null) { var childElement = _driver.FindElement(childLocator) as ITestWebElement; var iframe = childElement?.GetParentOfType("iframe") as ITestWebElement; if (iframe != null) { var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(10)); wait.IgnoreExceptionTypes(typeof(NoAlertPresentException)); wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(iframe.FoundBy)); } } _driver.SwitchTo().Frame(index); }
public void DragAndDrop() { var actions = new Actions(driver); var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(6)); driver.Navigate().GoToUrl("http://www.pureexample.com/jquery-ui/basic-droppable.html"); wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.Id("ExampleFrame-94"))); var source = driver.FindElement(By.XPath("//*[@class='square ui-draggable']")); var target = driver.FindElement(By.XPath("//*[@class='squaredotted ui-droppable']")); actions.DragAndDrop(source, target).Perform(); var text = driver.FindElement(By.Id("info")); Assert.AreEqual("dropped!", text.Text); }
public bool FrameVisibleWait() { try { WebDriverWait wait = new WebDriverWait(aControlAccess.Browser.BrowserHandle, TimeSpan.FromMilliseconds(10000)); wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(Utility.GetByFromLocator(aControlAccess.LocatorType, aControlAccess.Locator))); return(true); } catch (NullReferenceException ex) { return(false); } catch (Exception ex) { return(false); } }
public void TestDragAndDrop_02() { _driver.Navigate().GoToUrl("https://jqueryui.com/droppable/"); _wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.ClassName("demo-frame"))); var targetElement = _driver.FindElement(By.Id("droppable")); var sourceElement = _driver.FindElement(By.Id("draggable")); var drag = _actions .ClickAndHold(sourceElement) .MoveToElement(targetElement) .Release(targetElement) .Build(); drag.Perform(); Assert.AreEqual("Dropped!", targetElement.Text); }