本文整理汇总了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);
}
示例2: wprowadzText
public void wprowadzText()
{
IdzDoAllegro();
_input = _driver.FindElement(By.XPath(SelParametry.input));
_input.Clear();
_input.SendKeys("Xbox One");
Thread.Sleep(2000);
}
示例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());
}
}
示例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);
}
示例5: ClearText
/// <summary>
/// Method to clear text in text box.
///
/// </summary>
public void ClearText()
{
_testObject = WaitAndGetElement();
_testObject.Clear();
}
示例6: TypeField
public GuineaPigPage TypeField(IWebElement field, string data)
{
field.Clear();
field.SendKeys(data);
return this;
}
示例7: SetText
private void SetText(IWebElement element, string text)
{
element.Clear();
element.SendKeys(text);
}
示例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;
}
}
//.........这里部分代码省略.........
示例9: Execute
protected override void Execute(IWebDriver driver, dynamic context, IWebElement element)
{
element.Clear();
}
示例10: TryClear
private void TryClear(IWebElement element)
{
try
{
element.Clear();
}
catch (Exception ex)
{
ThrowNotAbleToExecuteAction(ex);
}
}
示例11: Type
public void Type(IWebElement element, string text)
{
element.Clear();
element.SendKeys(text);
}
示例12: ClearTextBox
public static void ClearTextBox(By locator)
{
_element = GenericHelper.GetElement(locator);
_element.Clear();
}
示例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);
});
}
示例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"));
}
示例15: Type
protected void Type(IWebElement webElement, string text)
{
webElement.Clear();
webElement.SendKeys(text);
}