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


C# IWebElement.Clear方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: ClearText

 /// <summary>
 /// Method to clear text in text box.
 /// 
 /// </summary>
 public void ClearText()
 {
     _testObject = WaitAndGetElement();
     _testObject.Clear();
 }
开发者ID:Thinksys,项目名称:krypton,代码行数:9,代码来源:TestObject.cs

示例6: TypeField

 public GuineaPigPage TypeField(IWebElement field, string data)
 {
     field.Clear();
     field.SendKeys(data);
     return this;
 }
开发者ID:Full360Solutions,项目名称:Saucery,代码行数:6,代码来源:GuineaPigPage.cs

示例7: SetText

 private void SetText(IWebElement element, string text)
 {
     element.Clear();
     element.SendKeys(text);
 }
开发者ID:ZeroTull,项目名称:MRA_Automation,代码行数:5,代码来源:AbstractPage.cs

示例8: SendKeys

        /// <summary>
        /// Method to type specied text in text box.
        /// </summary>
        /// <param name="text">string : Text to type on text box object</param>
        public void SendKeys(string text)
        {
            try
            {

                _testObject = WaitAndGetElement();

                //Check ON or OFF condition for radio button or checkbox.
                if (text.Equals("ON", StringComparison.CurrentCultureIgnoreCase) || (text.Equals("OFF", StringComparison.CurrentCultureIgnoreCase)))
                {
                    var objType = _testObject.GetAttribute("type");
                    if (objType.Equals("checkbox", StringComparison.CurrentCultureIgnoreCase) ||
                         objType.Equals("radio", StringComparison.CurrentCultureIgnoreCase))
                    {
                        switch (text.ToLower())
                        {
                            case "on":
                                Property.StepDescription = "Check " + _testObject.Text;
                                Check();
                                break;
                            case "off":
                                Property.StepDescription = "Uncheck " + _testObject.Text;
                                UnCheck();
                                break;
                        }
                    }
                }
                else
                {
                    //checking for frames.
                    string objTagName = string.Empty;
                    if (objTagName.ToLower().Equals("iframe") || objTagName.ToLower().Equals("frame"))
                    {
                        Driver.SwitchTo().Frame(_testObject); //Selecting the frame
                        Driver.FindElement(By.CssSelector("body")).SendKeys("text"); //entering the data to frame.
                    }
                    else
                    {
                        _testObject.Clear();
                        try
                        {
                            _testObject.SendKeys(text);
                        }
                        catch (ElementNotVisibleException enve)
                        {
                            try
                            {
                                ExecuteScript(_testObject, string.Format("arguments[0].value='{0}';", text));
                            }
                            catch
                            {
                                throw enve;
                            }
                        }
                        catch (Exception)
                        {
                            if (_objDataRow.ContainsKey(KryptonConstants.TEST_OBJECT))
                                throw new NoSuchElementException(Utility.GetCommonMsgVariable("KRYPTONERRCODE0069").Replace("{MSG3}", _objDataRow[KryptonConstants.TEST_OBJECT]).Replace("{MSG4}", _objDataRow["parent"]).Replace("{MSG1}", AttributeType).Replace("{MSG2}", Attribute)); // added by
                            throw;
                        }
                    }
                }
            }

            catch (StaleElementReferenceException)
            {
                _testObject = WaitAndGetElement();
                _testObject.Clear();
                try
                {
                    _testObject.SendKeys(text);
                }
                catch (Exception)
                {
                    if (_objDataRow.ContainsKey(KryptonConstants.TEST_OBJECT))
                        throw new NoSuchElementException(Utility.GetCommonMsgVariable("KRYPTONERRCODE0069").Replace("{MSG3}", _objDataRow[KryptonConstants.TEST_OBJECT]).Replace("{MSG4}", _objDataRow["parent"]).Replace("{MSG1}", AttributeType).Replace("{MSG2}", Attribute)); // added by
                    throw;
                }
            }
            catch (Exception e)
            {
                if (e.Message.Contains("Element is no longer attached to the DOM"))
                {
                    _testObject = WaitAndGetElement();
                    _testObject.Clear();
                    try
                    {
                        _testObject.SendKeys(text);
                    }
                    catch (Exception)
                    {
                        if (_objDataRow.ContainsKey(KryptonConstants.TEST_OBJECT))
                            throw new NoSuchElementException(Utility.GetCommonMsgVariable("KRYPTONERRCODE0069").Replace("{MSG3}", _objDataRow[KryptonConstants.TEST_OBJECT]).Replace("{MSG4}", _objDataRow["parent"]).Replace("{MSG1}", AttributeType).Replace("{MSG2}", Attribute)); // added by
                        throw;
                    }
                }
//.........这里部分代码省略.........
开发者ID:Thinksys,项目名称:krypton,代码行数:101,代码来源:TestObject.cs

示例9: Execute

 protected override void Execute(IWebDriver driver, dynamic context, IWebElement element)
 {
     element.Clear();
 }
开发者ID:MGetmanov,项目名称:Selenite,代码行数:4,代码来源:DoClearCommand.cs

示例10: TryClear

 private void TryClear(IWebElement element)
 {
     try
     {
         element.Clear();
     }
     catch (Exception ex)
     {
         ThrowNotAbleToExecuteAction(ex);
     }
 }
开发者ID:unclefil,项目名称:Blackbox-Testing-Automation,代码行数:11,代码来源:ActionExecutor.cs

示例11: Type

 public void Type(IWebElement element, string text)
 {
     element.Clear();
     element.SendKeys(text);
 }
开发者ID:maxraychev,项目名称:ct,代码行数:5,代码来源:PageObject.cs

示例12: ClearTextBox

 public static void ClearTextBox(By locator)
 {
     _element = GenericHelper.GetElement(locator);
     _element.Clear();
 }
开发者ID:rahulrathore44,项目名称:OutreachWebdriver,代码行数:5,代码来源:TextBoxHelper.cs

示例13: SendKeys

        /// <summary>
        /// Escreve no elemento selecionado
        /// </summary>
        /// <param name="element">Elemento</param>
        /// <param name="value">Valor que será preenchido</param>
        public void SendKeys(IWebElement element, string value)
        {
            string evidenceName = $"Escrevendo '{value}' no campo '{element.TagName}' ";

            _safeExecution.ExecuteWithEvidence(evidenceName, () =>
            {
                element.Clear();
                element.SendKeys(value);
            });
        }
开发者ID:govinda777,项目名称:Selenium,代码行数:15,代码来源:Element.cs

示例14: UpdateTest

        public void UpdateTest()
        {
            Login();
            element = driver.FindElement(By.XPath("//a[@href='/Posilki']"));
            element.Click();
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            element = driver.FindElement(By.XPath("//table/tbody/tr[last()]/td[3]/a[1]"));
            element.Click();
            element = driver.FindElement(By.Id("Name"));
            element.Click();
            element.Clear();
            element.SendKeys("edit Name");
            element = driver.FindElement(By.Id("Price"));
            element.Click();
            element.Clear();
            element.SendKeys("12.34");
            element = driver.FindElement(By.XPath("//input[@value='Save']"));
            element.Click();
            element = driver.FindElement(By.ClassName("table"));
            Assert.IsTrue(element.Text.Contains("edit Name $12.34"));

        }
开发者ID:dszczutkowski,项目名称:DSMVC,代码行数:22,代码来源:SeleniumTest.cs

示例15: Type

 protected void Type(IWebElement webElement, string text)
 {
     webElement.Clear();
     webElement.SendKeys(text);
 }
开发者ID:Kostin1987,项目名称:KKLTesting,代码行数:5,代码来源:BasePage.cs


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