本文整理汇总了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);
}
示例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());
}
}
示例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);
}
示例4: HandleElement
private void HandleElement(IWebElement el, IWebDriver browser, string[] parameters)
{
el.Clear();
var keystroke = KeywordUtility.ReadParameterValue(_variables, parameters[2]);
el.SendKeys(keystroke);
}
示例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;
}
}
示例6: wprowadzText
public void wprowadzText()
{
IdzDoAllegro();
_input = _driver.FindElement(By.XPath(SelParametry.input));
_input.Clear();
_input.SendKeys("Xbox One");
Thread.Sleep(2000);
}
示例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();
}
示例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());
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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();
}
}
示例13: PressEnter
public static void PressEnter(IWebElement iwe)
{
try
{
if (iwe == null) return;
iwe.SendKeys(Keys.Enter);
}
catch (NullReferenceException)
{
}
}
示例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);
}
}
示例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();
}