Is there any alternative for PageFactory using net core Is there any alternative for PageFactory using net core selenium selenium

Is there any alternative for PageFactory using net core


I'm using WebDriver V3.141.0.0 and .NET v4.5 and you can replace your code as follows:

using OpenQA.Selenium;using OpenQA.Selenium.Support.PageObjects;namespace Example{    public class Form    {        public IWebElement Filter => Driver.FindElement(By.Name("Filter"));           /*        [FindsBy(How = How.Name, Using = "Filter")] // This does exist in current context using .NET Core        public IWebElement Filter { get; set; }        */        public IWebElement Button => Driver.FindElement(By.TagName("Button"));           /*        [FindsBy(How = How.TagName, Using = "Button")]        public IWebElement Button;        */        public Form(IWebDriver driver)        {            //PageFactory.InitElements(driver, this); // This doesn't exist in current context using .NET Core        }    }}


Not specific to .Net Core but for .Net Standard 2.0 and .Net Framework(s) 3.5, 4.0, & 4.5 you should be able to add DotNetSeleniumExtras.PageObjects to your project to get PageFactory functionality once OpenQA.Selenium officially drops it. You would reference this by: using SeleniumExtras.PageObjects;


There is no PageFactory class in WebDriver.Support.dll for version 3.6.0 (In visual studio you can open this dll in object explorer and see that there is no such class). So you've got just usual compilation error.

I've looked source code on github https://github.com/SeleniumHQ/selenium/blob/master/dotnet/src/support/PageObjects/PageFactory.csand see preprocessor directive #if !NETSTANDARD2_0 ... #endif in PageFactory class. I don't know why NETSTANDARD2_0 affected NETCORE2_0, and not sure that it's real reason, but for us as library users PageFactory is unaccessible for now.