在硒C#中找不到类型或名称空间SelectElement [英] The type or namespace SelectElement could not be found in selenium c#
问题描述
driver.FindElement(By.Id("inputUsername")).SendKeys("aca");
driver.FindElement(By.Id("inputPassword")).SendKeys("123");
driver.FindElement(By.TagName("button")).Click();
SelectElement oSelect = new SelectElement(driver.FindElement(By.Id("selectFilterbyUser")));
oSelect.selectByText("Alex");
有人对我上面提到的问题有解决方案吗?尝试使用SelectElement
,但显示:
Do anyone have solution for the problem that i had attach in the above? Try to use SelectElement
but it displays:
The type or namespace `SelectElement` could not be found.
我试图查看潜在的修复程序,但是它只显示了三个选项
I tried to see the potential fixes, but it shows only three options which are
- 在新文件中生成类
SelectElement
- 生成类
SelectElement
- 生成嵌套类
SelectElement
- Generate class
SelectElement
in a new file - Generate class
SelectElement
- Generate nested class
SelectElement
有人知道如何解决吗?
推荐答案
参考之前的几篇文章,似乎您正在使用 nunittestadapter , NUnit.Framework ,使用NuGet Manager的 VS 2017 ,有时安装/配置可能存在问题.
Referring to a few previous posts it seems if you are using frameworks like nunittestadapter, NUnit.Framework, VS 2017 using the NuGet Manager sometimes there can be issues with the installation /configuration.
根据文档 SelectElement
> OpenQA.Selenium.Support.UI Namespace
,它提供了一种方便的方法来处理HTML select元素中的选项选择.
As per the documentation the SelectElement
Class is pretty much available within OpenQA.Selenium.Support.UI Namespace
which provides a convenience method for manipulating selections of options in an HTML select element.
继承层次结构
Inheritance Hierarchy
System.Object
OpenQA.Selenium.Support.UI.SelectElement
命名空间: OpenQA.Selenium.Support.UI
程序集: WebDriver.Support(在WebDriver.Support.dll中)版本:3.1.0
语法:公共类SelectElement:IWrapsElement
快照:
Snapshot:
卸载&重新安装Selenium.Webdriver和Selenium.Support软件包,这肯定会解决该问题.
Uninstall & reinstall the Selenium.Webdriver and Selenium.Support packages, that will surely fix the problem.
您可以在中找到相关的讨论在OpenQa Selenium 3.7中找不到WebDriverWait类
这篇关于在硒C#中找不到类型或名称空间SelectElement的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!