Selenium Webdriver C# Sendkeys (Keys.Arrowdown) [英] Selenium Webdriver C# Sendkeys (Keys.Arrowdown)

查看:44
本文介绍了Selenium Webdriver C# Sendkeys (Keys.Arrowdown)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Selenium Webdriver/C# compile 做一个箭头,但是当我尝试编译时出现此错误:

I'm trying to do do an arrow using Selenium Webdriver/C# compile but when I try to compile I get this error:

'Keys' 是 'OpenQA.Selenium.Keys' 和'System.Windows.Forms.Keys' (CS0104)

'Keys' is an ambiguous reference between 'OpenQA.Selenium.Keys' and 'System.Windows.Forms.Keys' (CS0104)

我的代码:

driver.FindElement(By.Id("ctl00_PlaceHolderMain_ctrlChangeBillingAddress_ctrlChangeBillingAddress_txtBillingAddress")).SendKeys(Keys.ArrowDown);
driver.FindElement(By.Id("ctl00_PlaceHolderMain_ctrlChangeBillingAddress_ctrlChangeBillingAddress_txtBillingAddress")).SendKeys(Keys.Enter);

推荐答案

如错误所述,在两个不同的命名空间中有两种不同的 Keys 类型.

As the error states, there are two different Keys types in two different namespaces.

您需要通过编写 OpenQA.Selenium.Keys 来明确限定类型.

You need to unambiguously qualify the type by writing OpenQA.Selenium.Keys.

这篇关于Selenium Webdriver C# Sendkeys (Keys.Arrowdown)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆