1

Selenium の PageFactory で C# を使用している人は、How.Custom ロケーターを実装する方法を知っていますか? 私はインターネットを高低から無駄に検索しました。すべての例は Java であり、それらでさえ、はるかに少ないようです。

4

1 に答える 1

3

次のようなクラスを作成します。

public class NgByModelFinder : By
{
    public NgByModelFinder(string locator)
    {
        FindElementMethod = (ISearchContext context) => context.FindElement(NgBy.Model(locator));
    }
}

次に、FindsBy 属性を Web 要素に次のようにアタッチします。

[FindsBy(How = How.Custom, Using = "value for locator", CustomFinderType = typeof(NgByModelFinder))]
protected IWebElement TestDiv { get; set; }

上記がお役に立てば幸いです。

于 2016-06-15T06:34:16.300 に答える