簡體   English   中英

SelectElement對象在Selenium C#中返回null

[英]SelectElement object returns null in Selenium C#

我在C#中使用Selenium,當嘗試從下拉列表中訪問並選擇一個值時,它不起作用。

我嘗試使用斷點進行調試,當我將光標移到SelectElement類對象的對象上時,它顯示為null。

但我知道一切正確。 是否使用id,name或xpath定位元素。

我正在使用chromedriver。

SelectElement ss = new SelectElement(driver.FindElement(By.Id("customer"))); 

我不確定您要選擇什么。 如果您要選擇一個下拉菜單,則可以使用它。

var customer = driver.FindElement(By.Id("customer"));
var selectElement = new SelectElement(customer);
selectElement.SelectByValue("customerType"); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM