public void GetElementsAsListTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; Assert.IsTrue(elementActions.GetElementsAsList(By.XPath("//ul/li")).Count > 0, "Element list wasn't created."); }
public void IsDisplayedIWebElementTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; Assert.IsTrue(elementActions.IsDisplayed(Driver.FindElement(By.XPath("//a[text()='A/B Testing']"))), "The A/B link wasn't displayed."); }
public LoginPage() { _wait = new Waits(); _fileLocations = new FileLocations(); _elementActions = new ElementActions(); PageFactory.InitElements(BeforeHooks.driver, this); }
public void IsEnabledByTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; Assert.IsTrue(elementActions.IsEnabled(By.XPath("//a[text()='A/B Testing']")), "The A/B link wasn't enabled."); }
public void GetTextByTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; Assert.AreEqual("Welcome to the-internet", elementActions.GetText(By.XPath("//h1")), "The text didn't match."); }
public void ClickIWebElementTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; elementActions.Click(Driver.FindElement(By.XPath("//a[text()='A/B Testing']"))); Assert.IsTrue(Driver.Url.Contains("/abtest"), "URL didn't contain '/abtest'."); }
public void GetSelectedOptionIWebElementTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://automate-apps.com/select-multiple-options-from-a-drop-down-list/"; elementActions.SelectDropdownValueByText(By.XPath("//select[@name='cars']"), "Honda"); Assert.AreEqual("Honda", elementActions.GetSelectedOption(Driver.FindElement(By.XPath("//select[@name='cars']"))).Text, "The selected options didn't match."); }
public void NestedChildFrameTest() { var elementActions = new ElementActions(Driver); Driver.Url = "https://demoqa.com/nestedframes"; var element = elementActions.FindElement(By.XPath("//p")); Assert.AreEqual("Child Iframe", element.Text, "The element text didn't match."); }
public void NoFrameTest() { var elementActions = new ElementActions(Driver); Driver.Url = "https://demoqa.com/nestedframes"; var element = elementActions.FindElement(By.XPath("//div[@class='main-header']")); Assert.AreEqual("Nested Frames", element.Text, "The element text didn't match."); }
public void BadElementTest() { var elementActions = new ElementActions(Driver); Driver.Url = "https://demoqa.com/nestedframes"; var element = elementActions.FindElement(By.XPath("//div[@class='false-header']")); Assert.IsNull(element, "The element object wasn't null."); }
public void SelectDropdownValueByIndexIWebElementTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; elementActions.Click(Driver.FindElement(By.XPath("//a[text()='Dropdown']"))); elementActions.SelectDropdownValueByIndex(Driver.FindElement(By.Id("dropdown")), 1); Assert.AreEqual("Option 1", elementActions.GetSelectedOption(Driver.FindElement(By.Id("dropdown"))).Text, "The selected dropdown values didn't match."); }
public void IsSelectedIWebElementTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; elementActions.Click(By.XPath("//a[text()='Checkboxes']")); elementActions.Click(By.XPath("//form[@id='checkboxes']/input[1]")); Assert.IsTrue(elementActions.IsSelected(Driver.FindElement(By.XPath("//form[@id='checkboxes']/input[1]"))), "The checkbox wasn't selected."); }
public void TypeIWebElementTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; elementActions.Click(Driver.FindElement(By.XPath("//a[text()='Forgot Password']"))); elementActions.Type(Driver.FindElement(By.XPath("//input[@id='email']")), "james"); Assert.AreEqual("james", Driver.FindElement(By.Id("email")).GetAttribute("value"), "The textbox values didn't match."); }
public void IsMultiSelectTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://automate-apps.com/select-multiple-options-from-a-drop-down-list/"; elementActions.SelectDropdownValueByText(By.XPath("//select[@name='cars']"), "Honda"); elementActions.SelectDropdownValueByText(By.XPath("//select[@name='cars']"), "BMW"); Assert.IsTrue(elementActions.GetAllSelectedOptions(Driver.FindElement(By.XPath("//select[@name='cars']"))).Count == 2, "The total selected dropdown options wasn't 2."); }
public void TypeByTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; elementActions.Click(Driver.FindElement(By.XPath("//a[text()='Forgot Password']"))); new WebDriverWait(Driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementIsVisible(By.XPath("//input[@id='email']"))); elementActions.Type(By.XPath("//input[@id='email']"), "james"); Assert.AreEqual("james", Driver.FindElement(By.Id("email")).GetAttribute("value"), "The textbox values didn't match."); }
public void HoverByTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; elementActions.Click(By.XPath("//a[text()='Hovers']")); Assert.IsFalse(elementActions.IsDisplayed(By.XPath("//h5[text()='name: user1']")), "The specified text isn't displayed."); elementActions.Hover(By.XPath("//div[@class='figure'][1]")); Assert.IsTrue(elementActions.IsDisplayed(By.XPath("//h5[text()='name: user1']")), "The specified text isn't displayed."); }
public void DragAndDropIWebElementTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; elementActions.Click(By.XPath("//a[text()='Drag and Drop']")); Assert.AreEqual("A", Driver.FindElement(By.XPath("//div[@id='columns']/div[1]/header")).Text); elementActions.DragAndDrop(Driver.FindElement(By.Id("column-a")), Driver.FindElement(By.Id("column-b"))); Assert.AreEqual("B", Driver.FindElement(By.XPath("//div[@id='columns']/div[1]/header")).Text, "The boxes didn't drag and drop."); }
public static ElementResult ExecuteAction(this ElementResult elementRef, ElementObject ele) { if (ele == null) { ele = new ElementObject(); } var ea = new ElementActions(elementRef.TE); return(ea.ExecuteAction(ele, elementRef)); }
public void IsAlertDisplayedTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; elementActions.Click(By.XPath("//a[text()='JavaScript Alerts']")); elementActions.Click(By.XPath("//button[text()='Click for JS Alert']")); elementActions.WaitForAlertToBeVisible(30); Assert.IsTrue(elementActions.IsAlertDisplayed(), "Alert wasn't displayed."); }
public void DeselectDropdownValueByValueIndexTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://automate-apps.com/select-multiple-options-from-a-drop-down-list/"; elementActions.SelectDropdownValueByText(By.XPath("//select[@name='cars']"), "BMW"); Assert.AreEqual("BMW", elementActions.GetSelectedOption(By.XPath("//select[@name='cars']")).Text, "The selected dropdown values didn't match."); elementActions.DeselectDropdownValueByIndex(Driver.FindElement(By.XPath("//select[@name='cars']")), 2); Assert.IsNull(elementActions.GetSelectedOption(By.XPath("//select[@name='cars']")), "The selected dropdown option wasn't null."); }
public void IframeIWebelementTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; elementActions.Click(By.XPath("//a[text()='Frames']")); elementActions.Click(By.XPath("//li/a[text()='iFrame']")); Assert.IsFalse(elementActions.IsDisplayed(By.Id("tinymce")), "The specified text isn't displayed."); elementActions.SwitchToFrame(Driver.FindElement(By.Id("mce_0_ifr"))); Assert.IsTrue(elementActions.IsDisplayed(By.Id("tinymce")), "The specified text isn't displayed."); }
public void SwitchToNewestWindowTest() { var browserActions = new BrowserActions(Driver); var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; elementActions.Click(By.XPath("//a[text()='Multiple Windows']")); elementActions.Click(By.XPath("//a[text()='Click Here']")); browserActions.SwitchToNewestWindow(); Assert.AreEqual("New Window", browserActions.GetPageTitle(), "The newest window page title didn't match."); }
public void DismissAlertTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; elementActions.Click(By.XPath("//a[text()='JavaScript Alerts']")); elementActions.Click(By.XPath("//button[text()='Click for JS Confirm']")); Assert.IsTrue(elementActions.IsAlertDisplayed(), "Alert wasn't displayed."); elementActions.DismissAlert(); Assert.IsFalse(elementActions.IsAlertDisplayed(), "Alert was still displayed."); }
public void GetAlertTextTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; elementActions.Click(By.XPath("//a[text()='JavaScript Alerts']")); elementActions.Click(By.XPath("//button[text()='Click for JS Alert']")); var text = elementActions.GetAlertText(); Assert.AreEqual("I am a JS Alert", text, "The alert text didn't match."); }
public void CustomDownloadFileLocationTest() { var elementActions = new ElementActions(Driver); Driver.Url = "http://the-internet.herokuapp.com/"; elementActions.Click(By.XPath("//a[text()='File Download']")); var items = elementActions.GetElementsAsList(By.XPath("//div[@class='example']/a")); var downloadFile = items[1].Text; var downloadPath = string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["DownloadLocation"].ToString()) ? $"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}\\downloads\\" : System.Configuration.ConfigurationManager.AppSettings["DownloadLocation"]; FileHelper.DeleteFile(downloadPath, downloadFile); elementActions.Click(items[1]); FileHelper.WaitForFileDownload(downloadFile, downloadPath); Assert.IsTrue(File.Exists($"{downloadPath}\\{downloadFile}"), "The file wasn't downloaded successfully."); }
public static List <ElementResult> ExecuteActions(this ElementResult elementRef, ElementObject ele) { if (!elementRef.Success) { return(new List <ElementResult>() { new ElementResult(elementRef.TE) }); } if (ele == null) { ele = new ElementObject(); } var ea = new ElementActions(elementRef.TE); return(ea.ExecuteActions(ele, elementRef)); }
public BasePage(IWebDriver driver) { ElementActions = new ElementActions(driver); BrowserActions = new BrowserActions(driver); }
public Page(IWebDriver driver) { Driver = driver; Actions = new ElementActions(Driver); }
public void LoginSuccessfully(string userName, string passWord) { ElementActions.AlertDataEnter(_driver, userName); ElementActions.AlertDataEnter(_driver, passWord); ElementActions.AlertAccept(_driver); }
public void LoginUnSuccessfully() { ElementActions.AlertDismiss(_driver); }