示例#1
0
文件: Library.cs 项目: yk-kuang/ci
        public void scrollToElement(byFields by, string element)
        {
            log("scrollToElement");
            IWebElement elem = driver.FindElement(getBy(by, element));

            ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", element);
        }
示例#2
0
文件: Library.cs 项目: yk-kuang/ci
 public bool isElementPresent(byFields by, string element)
 {
     log("isElementPresent(" + by + "," + element + ")");
     try
     {
         driver.FindElement(getBy(by, element));
         log("isElementPresent return: true");
         return(true);
     }
     catch (Exception)
     {
         log("isElementPresent return: false");
         return(false);
     }
 }
示例#3
0
文件: Library.cs 项目: yk-kuang/ci
        public void setDropDownText(byFields by, string element, string text, int timeOut)
        {
            log("setDropDownText(" + by + ", " + element + "," + text + ")");

            try
            {
                waitForElement(timeOut, getBy(by, element));
                new SelectElement(driver.FindElement(getBy(by, element))).SelectByText(text);
            }
            catch (Exception ex)
            {
                log("setdropdowntext error" + ex.ToString());
                methodError(ex);
            }
            takeScreenStep("setDropDownText");
        }
示例#4
0
文件: Library.cs 项目: yk-kuang/ci
        public void submitElement(byFields by, string element, int timeOut)
        {
            log("submitElement(" + by + ", " + element + ")");

            try
            {
                waitForElement(timeOut, getBy(by, element));
                driver.FindElement(getBy(by, element)).Submit();
            }
            catch (Exception ex)
            {
                log("submitelement error" + ex.ToString());
                methodError(ex);
            }
            takeScreenStep("submitElement");
        }
示例#5
0
文件: Library.cs 项目: yk-kuang/ci
        public string getValue(byFields by, string element, int timeOut)
        {
            log("getValue(" + by + ", " + element + ")");

            try
            {
                waitForElement(timeOut, getBy(by, element));
                driver.FindElement(getBy(by, element)).GetAttribute("value");
            }
            catch (Exception ex)
            {
                log("getvalue error" + ex.ToString());
                methodError(ex);
            }
            return(driver.FindElement(getBy(by, element)).GetAttribute("value"));
        }
示例#6
0
文件: Library.cs 项目: yk-kuang/ci
        public string getText(byFields by, string element, int timeOut)
        {
            log("getText(" + by + ", " + element + ")");

            try
            {
                waitForElement(timeOut, getBy(by, element));
                driver.FindElement(getBy(by, element)).Text.ToString();
            }
            catch (Exception ex)
            {
                log("gettext error" + ex.ToString());
                methodError(ex);
            }
            return(driver.FindElement(getBy(by, element)).Text);
        }
示例#7
0
文件: Library.cs 项目: yk-kuang/ci
        public void clickElement(byFields by, string element, int timeOut)
        {
            log("clickElement(" + by + ", " + element + ")");

            try
            {
                waitForElement(timeOut, getBy(by, element));
                driver.FindElement(getBy(by, element)).Click();
                waitOnPageLoad();
            }
            catch (Exception ex)
            {
                log("clickelement error" + ex.ToString());
                methodError(ex);
            }
            takeScreenStep("clickElement");
        }
示例#8
0
文件: Library.cs 项目: yk-kuang/ci
        public void sendText(byFields by, string element, string data, int timeOut, bool clear = false)
        {
            log("sendText(" + by + ", " + element + ", " + data + ", " + clear + ")");

            try
            {
                waitForElement(timeOut, getBy(by, element));
                if (clear)
                {
                    clearText(by, element, timeOut);
                }
                driver.FindElement(getBy(by, element)).Click();
                driver.FindElement(getBy(by, element)).SendKeys(data);
            }
            catch (Exception ex)
            {
                log("sendtext error" + ex.ToString());
                methodError(ex);
            }
            takeScreenStep("sendText");
        }
示例#9
0
文件: Library.cs 项目: yk-kuang/ci
 public By getBy(byFields by, String element)
 {
     if (by == byFields.id)
     {
         return(By.Id(element));
     }
     else if (by == byFields.name)
     {
         return(By.Name(element));
     }
     else if (by == byFields.css)
     {
         return(By.CssSelector(element));
     }
     else if (by == byFields.tag)
     {
         return(By.TagName(element));
     }
     else if (by == byFields.className)
     {
         return(By.ClassName(element));
     }
     else if (by == byFields.linkText)
     {
         return(By.LinkText(element));
     }
     else if (by == byFields.partialLinkText)
     {
         return(By.PartialLinkText(element));
     }
     else if (by == byFields.xpath)
     {
         return(By.XPath(element));
     }
     else
     {
         return(By.Id(""));
     }
 }