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 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 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 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 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 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 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 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 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 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 ClickLogin() { _elementActions.Click(login); }
public void ClickRegister() { _elementActions.Click(register); }