[英]SelectElement object returns null in Selenium C#
I am using Selenium with C# and when trying to access and select a value from the dropdown, it's not working. 我在C#中使用Selenium,当尝试从下拉列表中访问并选择一个值时,它不起作用。
I tried to debug using breakpoint, when I move cursor on object of SelectElement class object, it's showing null. 我尝试使用断点进行调试,当我将光标移到SelectElement类对象的对象上时,它显示为null。
But I know everything is correct. 但我知道一切正确。 whether we use id, name or xpath to locate the element.
是否使用id,name或xpath定位元素。
I am using chromedriver. 我正在使用chromedriver。
SelectElement ss = new SelectElement(driver.FindElement(By.Id("customer")));
I'm not sure what you are trying to select. 我不确定您要选择什么。 If you are trying to select a drop down, then you can use this.
如果您要选择一个下拉菜单,则可以使用它。
var customer = driver.FindElement(By.Id("customer"));
var selectElement = new SelectElement(customer);
selectElement.SelectByValue("customerType");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.