Ejemplo n.º 1
0
        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.");
        }
Ejemplo n.º 2
0
        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.");
        }
Ejemplo n.º 3
0
        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.");
        }
Ejemplo n.º 4
0
        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.");
        }
Ejemplo n.º 5
0
        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.");
        }
Ejemplo n.º 6
0
        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.");
        }
Ejemplo n.º 7
0
        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.");
        }
Ejemplo n.º 8
0
        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'.");
        }
Ejemplo n.º 9
0
        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.");
        }
Ejemplo n.º 10
0
        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.");
        }
Ejemplo n.º 11
0
        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.");
        }
Ejemplo n.º 12
0
        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.");
        }
Ejemplo n.º 13
0
        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.");
        }
Ejemplo n.º 14
0
 public void ClickLogin()
 {
     _elementActions.Click(login);
 }
Ejemplo n.º 15
0
 public void ClickRegister()
 {
     _elementActions.Click(register);
 }