当前位置: 首页>>代码示例>>C#>>正文


C# IWebElement.SendKeys方法代码示例

本文整理汇总了C#中IWebElement.SendKeys方法的典型用法代码示例。如果您正苦于以下问题:C# IWebElement.SendKeys方法的具体用法?C# IWebElement.SendKeys怎么用?C# IWebElement.SendKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IWebElement的用法示例。


在下文中一共展示了IWebElement.SendKeys方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EnterData

        public void EnterData(ISearchContext context, IWebElement element, object data)
        {
            var options = findOptions(element);
            foreach (var option in options)
            {
                if (option.Text == data.ToString())
                {
                    option.Click();
                    element.SendKeys(Keys.Tab);
                    return;
                }
            }

            foreach (var option in options)
            {
                if (option.GetAttribute("value") == data.ToString())
                {
                    option.Click();
                    element.SendKeys(Keys.Tab);
                    return;
                }
            }

            var message = "Cannot find the desired option\nThe available options are\nDisplay/Key\n";
            foreach (var option in options)
            {
                message += "\n" + "{0}/{1}".ToFormat(option.Text, option.GetAttribute("value"));
            }

            StoryTellerAssert.Fail(message);
        }
开发者ID:DarthFubuMVC,项目名称:Serenity,代码行数:31,代码来源:SelectElementHandler.cs

示例2: FillElement

        protected void FillElement(IWebElement element, object value)
        {
            if (value == null)
            {
                return;
            }

            if (IsInput(element))
            {
                String inputType = element.GetAttribute("type");
                if (inputType == null || inputType == TextInputType || inputType == PasswordInputType)
                {
                    element.SendKeys(value.ToString());
                }
                else if (inputType == CheckboxType)
                {
                    CheckBox checkBox = new CheckBox(element);
                    checkBox.Set(bool.Parse(value.ToString()));
                }
                else if (inputType == RadioType)
                {
                    Radio radio = new Radio(element);
                    radio.SelectByValue(value.ToString());
                }
            }
            else if (IsSelect(element))
            {
                Select select = new Select(element);
                select.SelectByValue(value.ToString());
            }
            else if (IsTextArea(element))
            {
                element.SendKeys(value.ToString());
            }
        }
开发者ID:VNikita,项目名称:Test_auto,代码行数:35,代码来源:Form.cs

示例3: EnterData

        public void EnterData(ISearchContext context, IWebElement element, object data)
        {
            while (element.GetAttribute("value").IsNotEmpty())
            {
                element.SendKeys(Keys.Backspace);
            }

            element.SendKeys(data as string ?? string.Empty);
        }
开发者ID:jemacom,项目名称:fubumvc,代码行数:9,代码来源:TextboxElementHandler.cs

示例4: HandleElement

        private void HandleElement(IWebElement el, IWebDriver browser, string[] parameters)
        {
            el.Clear();
            var keystroke = KeywordUtility.ReadParameterValue(_variables, parameters[2]);

            el.SendKeys(keystroke);
        }
开发者ID:rainymaple,项目名称:WebTester,代码行数:7,代码来源:SendKeys.cs

示例5: FillOutLoginForm

        public static bool FillOutLoginForm(IWebDriver driver, string username, string password, IWebElement submitButton = null, IWebElement usernameField = null, IWebElement passwordField = null)
        {
            try
            {
                if (usernameField == null && driver.FindElements(By.XPath(txtUsernameXPath)).Count > 0)
                    usernameField = driver.FindElement(By.XPath(txtUsernameXPath));
                if (passwordField == null && driver.FindElements(By.XPath(txtPasswordXPath)).Count > 0)
                    passwordField = driver.FindElement(By.XPath(txtPasswordXPath));
                if (submitButton == null && driver.FindElements(By.XPath(btnSubmitXPath)).Count > 0)
                    submitButton = driver.FindElement(By.XPath(btnSubmitXPath));

                if (usernameField != null && passwordField != null && submitButton != null)
                {
                    usernameField.SendKeys(username);
                    passwordField.SendKeys(password);
                    submitButton.SendKeys(Keys.Enter);

                    return true;
                }

                return false;

            }
            catch (IllegalLocatorException e)
            {
                return false;
            }
        }
开发者ID:DaveGoosem,项目名称:SeleniumWebdriverBase,代码行数:28,代码来源:CommonLibrary.cs

示例6: wprowadzText

 public void wprowadzText()
 {
     IdzDoAllegro();
     _input = _driver.FindElement(By.XPath(SelParametry.input));
     _input.Clear();
     _input.SendKeys("Xbox One");
     Thread.Sleep(2000);
 }
开发者ID:marcinkoczan,项目名称:selenium,代码行数:8,代码来源:UnitTest1.cs

示例7: HandleElement

        private void HandleElement(IWebElement el, IWebDriver browser, string[] parameters)
        {
            var keystroke = KeywordUtility.ReadParameterValue(_variables, parameters[2]);

            el.SendKeys(keystroke);
            //switch to default content
            browser.SwitchTo().DefaultContent();
        }
开发者ID:rainymaple,项目名称:WebTester,代码行数:8,代码来源:SendKeysInEditor.cs

示例8: ClearAndFillTextBox

 /// <summary>
 /// Clear and then fill a textbox
 /// Great to ensure textbox filled as desired
 /// </summary>
 /// <param name="elem"></param>
 /// <param name="text"></param>
 public static void ClearAndFillTextBox(IWebElement elem, string text)
 {
     elem.Clear();
     if (!CheckNull(text))
     {
         elem.SendKeys(text.Trim());
     }
 }
开发者ID:CSlatton,项目名称:hello-world,代码行数:14,代码来源:SeleniumHelper.cs

示例9: EraseData

 public virtual void EraseData(ISearchContext context, IWebElement element)
 {
     if (element.GetAttribute("value").IsNotEmpty())
     {
         element.Click();
         element.SendKeys(Keys.Home + Keys.Shift + Keys.End + Keys.Backspace);
     }
 }
开发者ID:DarthFubuMVC,项目名称:Serenity,代码行数:8,代码来源:TextboxElementHandler.cs

示例10: EnterData

        public void EnterData(ISearchContext context, IWebElement element, object data)
        {
            if (element.Text.IsNotEmpty() || element.GetAttribute("value").IsNotEmpty())
            {
                element.Clear();
            }

            element.SendKeys(data as string ?? string.Empty);
        }
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:9,代码来源:TextAreaElementHandler.cs

示例11: Execute

        protected override void Execute(IWebDriver driver, dynamic context, IWebElement element)
        {
            var resolvedKeys = Test.ResolveMacros(Keys);

            // HACK: Firefox has issues with typing long strings.
            if (context.DriverType == DriverType.Firefox)
            {
                foreach (var key in resolvedKeys)
                {
                    Thread.Sleep(50);
                    element.SendKeys(key.ToString());
                }
            }
            else
            {
                element.SendKeys(resolvedKeys);
            }
        }
开发者ID:MGetmanov,项目名称:Selenite,代码行数:18,代码来源:DoSendKeysCommand.cs

示例12: Cheat

        private static void Cheat(IWebDriver firefoxDriver, IWebElement eInputField, List<string> words)
        {
            for (int i = 0; i < words.Count; i++) {
                if (bShouldShutDown) {
                    break;
                }

                eInputField.SendKeys(words[i]);
                new Actions(firefoxDriver).SendKeys(OpenQA.Selenium.Keys.Space).Perform();
            }
        }
开发者ID:Ald0s,项目名称:10fastfingers-autotyper,代码行数:11,代码来源:Program.cs

示例13: PressEnter

 public static void PressEnter(IWebElement iwe)
 {
     try
     {
         if (iwe == null) return;
         iwe.SendKeys(Keys.Enter);
     }
     catch (NullReferenceException)
     {
     }
 }
开发者ID:rohanbaraskar,项目名称:SeleniumAutomationFramework,代码行数:11,代码来源:SeleniumHelper.cs

示例14: enterdata

 static void enterdata(IWebElement elm, string val, string dynval)
 {
     if (dynval.Length > 0)
     {
         if ( dynval.ToLower() == "timestamp")
         {
             DateTime dt = DateTime.Now;
             elm.SendKeys(val+" " + dt.ToString("dd-MMM-yyyy hh:mm:ss"));
         }
         if (dynval.ToLower() == "guid")
         {
             Guid g = Guid.NewGuid();
             elm.SendKeys(val+"  "+  g.ToString().Substring(1,12));
         }
     }
     else
     {
         elm.SendKeys(val);
     }
 }
开发者ID:prasannarhegde2015,项目名称:EJcehck2,代码行数:20,代码来源:BabySeleniumFramework.cs

示例15: Click

        public static void Click(this IWebDriver driver, IWebElement element, DriverType driverType)
        {
            // HACK: Force Focus, to help prevent a problem with clicking in IE
            if (driverType == DriverType.InternetExplorer)
                driver.SwitchTo().Window(driver.CurrentWindowHandle);

            // HACK: There is an issue where mouse over events occure on Click that cover the buttons and cause a miss click.
            if (driverType == DriverType.Firefox && "input".Equals(element.TagName, StringComparison.InvariantCultureIgnoreCase))
                element.SendKeys(Keys.Space);
            else
                element.Click();
        }
开发者ID:MGetmanov,项目名称:Selenite,代码行数:12,代码来源:WebDriverExtensions.cs


注:本文中的IWebElement.SendKeys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。