11

Selenium Webdriver/C# コンパイルを使用して矢印を実行しようとしていますが、コンパイルしようとすると次のエラーが発生します。

「キー」は、「OpenQA.Selenium.Keys」と「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);
4

6 に答える 6

24

エラーが示すように、Keys2 つの異なる名前空間に 2 つの異なる型があります。

を記述して、型を明確に修飾する必要がありますOpenQA.Selenium.Keys

于 2012-06-03T03:37:33.753 に答える
5

2 つの認識を提供できますが、最初の認識はローカルでのみ機能します。

  1. Element.SendKeys(OpenQA.Selenium.Keys.ArrowUp);

  2. char c = '\uE013'; // ASCII code ArrowUp

    Element.SendKeys(Convert.ToString(c));

于 2013-09-03T08:14:57.670 に答える
-1

Actions クラスは、キーボードとマウスのイベントを処理するために Selenium によって提供される機能です。Selenium WebDriver では、これらのイベントの処理には、ドラッグ アンド ドロップ、コントロール キーによる複数の要素のクリックなどの操作が含まれます。

    IWebDriver driver = new ChromeDriver();
    Actions action = new Actions(driver);
    action.SendKeys(Keys.UpArrow);
    action.Build().Perform();   // build and perform is used to complete that particular action. 
    action = new Actions(driver); // reinitialize 
    action.SendKeys(Keys.DownArrow);
    action.Build().Perform(); 
于 2021-04-21T17:54:19.493 に答える