Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Selenium.NET驱动程序上IWebElement的基类?_C#_Selenium_Selenium Webdriver - Fatal编程技术网

C# Selenium.NET驱动程序上IWebElement的基类?

C# Selenium.NET驱动程序上IWebElement的基类?,c#,selenium,selenium-webdriver,C#,Selenium,Selenium Webdriver,带C#的Selenium WebDriver 我想做的就是找出IWebElement的基类是什么。 我在网上任何地方都找不到。这里有人能帮我弄清楚吗 我开始实现PageObject设计模式。我有一个名为Grid的PageObject,我想将其视为IWebElement,这样它就可以执行。单击(),.GetAttribute(),和.SendKeys()。当我这样做时: public class Grid : IWebElement { } 它迫使我实现IWebElement中的所有方法,但我希

带C#的Selenium WebDriver

我想做的就是找出
IWebElement
的基类是什么。

我在网上任何地方都找不到。这里有人能帮我弄清楚吗

我开始实现PageObject设计模式。我有一个名为
Grid
的PageObject,我想将其视为
IWebElement
,这样它就可以执行
。单击()
,.
GetAttribute()
,和
.SendKeys()
。当我这样做时:

public class Grid : IWebElement
{
}
它迫使我实现
IWebElement
中的所有方法,但我希望它们所做的只是默认它们已经实现的行为

我认为实现这一点的方法是找到
IWebElement
扩展自的基类,并让grid从扩展至,但我在任何地方都找不到它

如果有人能提供帮助,告诉我一种不同的方法来实现我的目标,
Grid
被视为
IWebElement
,我将非常感激!提前感谢。

OP说:

我想做的就是弄清楚IWebElement的基类是什么


首先,
IWebElement
是一个接口,因此它没有基类

基本上,您正在寻找默认的
IWebElement
实现:
RemoteWebElement

检查它的源代码

此外,
RemoteWebElement
是浏览器供应商专用实现的基类。例如,有一个

更新 OP在一些评论中说:


我想我应该重新措辞。我想做的就是上网格课 扩展IWebElement的功能,并能够被视为 IWebElement.–

IMHO,如果您使用而不是继承来提供这样的定制,您将更加高效。如果使用继承方法,则需要从所有特定于供应商的
RemoteWebElement
类派生,以便为Selenium支持的所有Web浏览器提供自定义

总结。你为什么不使用计算机来实现你的目标


通过这种方式,您将扩展任何
IWebElement
实现,您的定制将可用于所有浏览器

IWebElement
是一个接口。因此,它不能有一个基类…那么我该如何做我想做的呢?所以,如果我让网格扩展RemoteWebElement,那么我的任务就完成了?我想我应该重新措辞。我所要做的就是让Grid类扩展IWebElement的功能,并能够被视为IWebElement。@kdeez顺便说一句,如果您想支持多个浏览器,您需要提供一个特定于供应商的
RemoteWebElement
类的派生类:
FirefoxWebElement
ChromeWebElement
..@kdeez让我建议您另一种方法(我将改进我的答案…)。我尝试让它扩展RemoteWebElement,但当我为包含网格引用的类调用PageFactory.InitElements()时,它仍然抱怨它不是IWebElement。
public static class GridWebElementExtensions 
{
      public static IWebElement Whatever(this IWebElement element)
      {
          // Do stuff here
      }
}