コード例 #1
0
        public void TestAttributeWithNoTagNameAndPropertyThrowsAnException()
        {
            var attribute = new ElementLocatorAttribute {
                Type = "submit"
            };

            LocatorBuilder.GetElementLocators(attribute);
        }
コード例 #2
0
        public void TestAttributeWithNoTagNameAndPropertyThrowsAnException()
        {
            var attribute = new ElementLocatorAttribute {
                Type = "submit"
            };

            Assert.Throws <ElementExecuteException>(() =>
                                                    LocatorBuilder.GetElementLocators(attribute));
        }
コード例 #3
0
        public void TestAttributeWithLinkTextReturnsLinkTextLocator()
        {
            var attribute = new ElementLocatorAttribute {
                Text = "Hello World"
            };

            var resultList = LocatorBuilder.GetElementLocators(attribute);

            Assert.AreEqual(1, resultList.Count);
            var item = resultList.First();

            Assert.AreEqual(By.LinkText("Hello World"), item);
        }
コード例 #4
0
        public void TestAttributeWithCssClassReturnsCssClassLocator()
        {
            var attribute = new ElementLocatorAttribute {
                Class = ".something"
            };

            var resultList = LocatorBuilder.GetElementLocators(attribute);

            Assert.AreEqual(1, resultList.Count);
            var item = resultList.First();

            Assert.AreEqual(By.ClassName(".something"), item);
        }
コード例 #5
0
        public void TestAttributeWithNameReturnsNameLocator()
        {
            var attribute = new ElementLocatorAttribute {
                Name = "MyName"
            };

            var resultList = LocatorBuilder.GetElementLocators(attribute);

            Assert.AreEqual(1, resultList.Count);
            var item = resultList.First();

            Assert.AreEqual(By.Name("MyName"), item);
        }
コード例 #6
0
        public void TestAttributeWithIdReturnsCssSelectorLocator()
        {
            var attribute = new ElementLocatorAttribute {
                CssSelector = "div#MyId"
            };

            var resultList = LocatorBuilder.GetElementLocators(attribute);

            Assert.AreEqual(1, resultList.Count);
            var item = resultList.First();

            Assert.AreEqual(By.CssSelector("div#MyId"), item);
        }
コード例 #7
0
        public void TestAttributeWithTagNameAndTypeAndTitleReturnsCompoundXPathLocator()
        {
            var attribute = new ElementLocatorAttribute {
                TagName = "input", Type = "email", Title = "my title"
            };

            var resultList = LocatorBuilder.GetElementLocators(attribute);

            Assert.AreEqual(1, resultList.Count);
            var item = resultList.First();

            Assert.AreEqual(By.XPath("//input[@title='my title' and @type='email']"), item);
        }
コード例 #8
0
        public void TestAttributeWithTagNameAndTypeAndIndexReturnsComplexXPathLocator()
        {
            var attribute = new ElementLocatorAttribute {
                TagName = "input", Type = "email", Index = 1
            };

            var resultList = LocatorBuilder.GetElementLocators(attribute);

            Assert.AreEqual(1, resultList.Count);
            var item = resultList.First();

            Assert.AreEqual(By.XPath("(//input[@type='email'])[0]"), item);
        }
コード例 #9
0
        public void TestAttributeWithLinkAreaTagAndUrlReturnsXPathLocator()
        {
            var attribute = new ElementLocatorAttribute {
                TagName = "area", Url = "mylink.htm"
            };

            var resultList = LocatorBuilder.GetElementLocators(attribute);

            Assert.AreEqual(1, resultList.Count);
            var item = resultList.First();

            Assert.AreEqual(By.XPath("//area[@href='mylink.htm']"), item);
        }
コード例 #10
0
        public void TestAttributeWithImageTagAndUrlReturnsXPathLocator()
        {
            var attribute = new ElementLocatorAttribute {
                TagName = "img", Url = "myimage.png"
            };

            var resultList = LocatorBuilder.GetElementLocators(attribute);

            Assert.AreEqual(1, resultList.Count);
            var item = resultList.First();

            Assert.AreEqual(By.XPath("//img[@src='myimage.png']"), item);
        }
コード例 #11
0
        public void TestAttributeWithIdReturnsIdLocator()
        {
            var attribute = new ElementLocatorAttribute {
                Id = "MyId"
            };

            var resultList = LocatorBuilder.GetElementLocators(attribute);

            Assert.AreEqual(1, resultList.Count);
            var item = resultList.First();

            Assert.AreEqual(By.Id("MyId"), item);
        }
コード例 #12
0
        public void TestAttributeWithXPathReturnsXPathLocator()
        {
            var attribute = new ElementLocatorAttribute {
                XPath = ".//[@element='row']"
            };

            var resultList = LocatorBuilder.GetElementLocators(attribute);

            Assert.AreEqual(1, resultList.Count);
            var item = resultList.First();

            Assert.AreEqual(By.XPath(".//[@element='row']"), item);
        }
コード例 #13
0
        public void TestAttributeWithTagNameAndAltReturnsXPathLocator()
        {
            var attribute = new ElementLocatorAttribute {
                TagName = "input", Alt = "test"
            };

            var resultList = LocatorBuilder.GetElementLocators(attribute);

            Assert.AreEqual(1, resultList.Count);
            var item = resultList.First();

            Assert.AreEqual(By.XPath("//input[@alt='test']"), item);
        }
コード例 #14
0
        public void TestAttributeWithTagNameReturnsTagLocator()
        {
            var attribute = new ElementLocatorAttribute {
                TagName = "input"
            };

            var resultList = LocatorBuilder.GetElementLocators(attribute);

            Assert.AreEqual(1, resultList.Count);
            var item = resultList.First();

            Assert.AreEqual(By.TagName("input"), item);
        }
コード例 #15
0
        public void TestAttributeWithIdAndTagNameReturnsTwoLocators()
        {
            var attribute = new ElementLocatorAttribute {
                Id = "MyId", TagName = "a"
            };

            var resultList = LocatorBuilder.GetElementLocators(attribute);

            Assert.AreEqual(2, resultList.Count);

            var item = resultList.First();

            Assert.AreEqual(By.Id("MyId"), item);

            var item2 = resultList.Last();

            Assert.AreEqual(By.TagName("a"), item2);
        }