[英]C# with Selenium: "SelectElement" does not exist in the current context
我正在嘗試從下拉列表中選擇一些內容。 我不明白為什么我會收到錯誤。 我已經初始化了以下內容:
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
錯誤說:“SelectElement”在當前上下文中不存在。
IWebDriver myDriver = new ChromeDriver();
IWebElement currency = myDriver.FindElement(By.ClassName("SelecInput"));
var selectElement = SelectElement(currency);
selectElement.SelectByText("qwe");
很抱歉缺乏知識。 剛開始用 Selenium 學習 C#。 謝謝您的幫助。
SelectElement 是一個構造函數,你需要實例化它。
var selectElement = new SelectElement(currency);
您需要先安裝包 WebDriver.Support,它是獨立於 WebDriver.Selenium 的包
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.