コード例 #1
0
ファイル: IsTextPresent.cs プロジェクト: anthrax3/selenium-2
        protected override object HandleSeleneseCommand(IWebDriver driver, string pattern, string ignored)
        {
            string              text     = string.Empty;
            IWebElement         body     = driver.FindElement(By.XPath("/html/body"));
            IJavaScriptExecutor executor = driver as IJavaScriptExecutor;

            if (executor == null)
            {
                text = body.Text;
            }
            else
            {
                text = JavaScriptLibrary.CallEmbeddedHtmlUtils(driver, "getTextContent", body).ToString();
            }

            text = text.Trim();

            string strategyName = "implicit";
            string use          = pattern;

            if (TextMatchingStrategyAndValueRegex.IsMatch(pattern))
            {
                Match textMatch = TextMatchingStrategyAndValueRegex.Match(pattern);
                strategyName = textMatch.Groups[1].Value;
                use          = textMatch.Groups[2].Value;
            }

            ITextMatchingStrategy strategy = textMatchingStrategies[strategyName];

            return(strategy.IsAMatch(use, text));
        }
コード例 #2
0
ファイル: Highlight.cs プロジェクト: KirillJacobson/Selenium2
        /// <summary>
        /// Handles the command.
        /// </summary>
        /// <param name="driver">The driver used to execute the command.</param>
        /// <param name="locator">The first parameter to the command.</param>
        /// <param name="value">The second parameter to the command.</param>
        /// <returns>The result of the command.</returns>
        protected override object HandleSeleneseCommand(IWebDriver driver, string locator, string value)
        {
            JavaScriptLibrary.CallEmbeddedHtmlUtils(driver, "highlight", this.finder.FindElement(driver, locator));

            return(null);
        }