2017-10-11 86 views
0

我使用页面对象模型模式和PageFactory来初始化IWebElement属性/字段。我的问题是,我想要派生类与不同的[FindsBy]属性重写了IWebElement。我的基类:Selenium覆盖派生类中的FindsBy属性

public class ConfigurationMenuPage : PageInfo, IConfigurationMenuPage 
{ 
    private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); 

    [FindsBy(How = How.Id, Using = "ctl00_contents_ctl27")] 
    protected virtual IWebElement _campaignsConfigLink { get; set; } 

我的派生类:

public class ConfigurationMenuPage21 : ConfigurationMenuPage 
{ 
    [FindsBy(How = How.Id, Using = "otherId")] 
    protected sealed override IWebElement _campaignsConfigLink { get; set; } 

的问题是,_campaignsConfigLink财产与基础属性初始化(ID为“ctl00_contents_ctl27),而不是overrided一个(id为otherId)如何。我可以强制overrided属性初始化其属性FindsBy?

问候,

Cybul26

回答

0

为什么不只是删除ConfigurationMenuPage中的声明并让派生类声明它?一种解决方法是使用带有OR运算符的#ctl00_contents_ctl27, #otherId的CSS选择器。

+0

感谢您的重播。我决定'ConfigurationMenuPage'是一个具有抽象属性的抽象类,并让派生类声明它的属性。 –