예제 #1
0
        public void TypeIntoTextBoxLabelled(string p0, string p1)
        {
            var xPath = string.Format(@"//label[contains(text(),'{0}')]", p1);
            var label = Br.FindElement(By.XPath(xPath));

            ClearAndType(p0, label.GetAttribute("for"));
        }
예제 #2
0
        public void SelectFromTheDropdown(string p0, string p1)
        {
            var xPath = string.Format(@".//option[contains(text(),'{0}')]", p0);
            var ddl   = Br.FindElement(By.Id(p1));

            ddl.FindElement(By.XPath(xPath)).Click();
        }
예제 #3
0
        public void ClickTheCheckboxLabelled(string p0)
        {
            var xPath = string.Format(@"//label[contains(text(),'{0}')]", p0);
            var label = Br.FindElement(By.XPath(xPath));

            Br.FindElement(By.Id(label.GetAttribute("for"))).Click();
        }
예제 #4
0
        protected void ClearAndType(string p0, string p1)
        {
            Br.FindElement(By.Id(p1)).Clear();
            p0 = (p0.Contains(@"uniquevalue")) ? p0.Replace(@"uniquevalue", GuidString()) : p0;
            p0 = (p0.Contains(@"cache"))
                ? FeatureContext.Current.Get <string>(p0.Substring(p0.LastIndexOf('.') + 1))
                : p0;
            p0 = (p0.Contains(@"config"))
                ? ConfigurationManager.AppSettings[p0.Substring(p0.LastIndexOf('.') + 1)]
                : p0;

            Br.FindElement(By.Id(p1)).SendKeys(p0);
        }
예제 #5
0
        public void ThenTheDivWithShouldContainTheText(string p0, string p1, string p2)
        {
            IWebElement div = null;

            switch (p0.ToUpper())
            {
            case "TITLE":
                div = Br.FindElement(By.XPath(@"//div[@title='" + p1 + "']"));
                break;

            case "ID":
                div = Br.FindElement(By.Id(p1));
                break;
            }
            Assert.IsNotNull(div);
            Assert.IsTrue(div.Text.Contains(p2));
        }
예제 #6
0
        public void SelectFromTheDropdownLabelled(string p0, string p1)
        {
            var id     = string.Empty;
            var xPath  = string.Format(@"//label[contains(text(),'{0}')]", p1);
            var labels = Br.FindElements(By.XPath(xPath));

            foreach (var label in labels.Where(label => label.GetAttribute("for") != null))
            {
                id = label.GetAttribute("for");
                break;
            }

            xPath = string.Format(@".//option[contains(text(),'{0}')]", p0);
            var ddl = Br.FindElement(By.Id(id));

            ClickWithRetry(By.XPath(xPath));
        }
예제 #7
0
        protected void ClickWithRetry(By by)
        {
            var attempts = 0;

            while (attempts < 2)
            {
                try
                {
                    Br.FindElement(by).Click();
                    break;
                }
                catch (StaleElementReferenceException e)
                {
                }
                attempts++;
            }
        }
예제 #8
0
 public void ClickHyperLink(string p0)
 {
     Br.FindElement(By.XPath(@"//a[text()='" + p0 + "']")).Click();
 }
예제 #9
0
        public void SelectTheNthCheckbox(string p0)
        {
            var xPath = string.Format(@"//input[@type='checkbox'][{0}]", GetIndexFromPosition(p0));

            Br.FindElement(By.XPath(xPath)).Click();
        }