0

I just discovered the page object design pattern recently and really wanted to implement it into my company's UI Test Automation suite. I started to do so and immediately ran into problems which lead me to discovering Jim Evan's blog discussing the deprecation of Page Factory and Expected Conditions and their movement to a github project.

My question is - How do I now incorporate this project into my solution? I can't find a definitive answer on if there is a namespace setup for this project through NuGet, and I'm still learning Visual Studio/.NET as a whole so this is pretty new to me. Additionally, is there a better/different way to incorporate Page Objects without using Page Factory?

Thanks!

  • 2
    Just for the record, question is not about PageObject/PageFactory design pattern, but about certain .NET library implementation, which is deprecated and looking for a new maintainer. – Peter M. - stands for Monica Apr 2 '18 at 15:31
3

From the link you provided, library is still there and you are free to use it. With disclaimer that it is no longer maintained, and possible there could be other such libraries with more community support, which would be better, more future-proof candidates to base your design on.

Originally, it seems that this code was intermixed with other .NET code for Selenium, and developers extracted it into a separate entity, so they separate the core part which they do plan to support, and PageFactory, which they don't intend to support in the future.

Or, in near future someone from existing users might decide that their previous investment in it is too valuable and decide to maintain it.

It is ALWAYS this risk you have to evaluate when picking a technology/library in any of your projects, and you have to ask: How healthy is this technology? Does it have support? Will it's support continue in timeframe my project will use it? You don't want to be last person using some obsolete technology.

At minimum, try to find if there is a list/forum/whatever for the current users and/or developers for this deprecated library. Maybe there is somewhere, and they plan to announce the support soon? Google for blogs post from developers/committers, etc.

One problem with using such generic name for a project (".NET PageFactory") is that it is hard/impossible to find relevant hits in google search results.

  • Thanks for your answer Peter - I guess my question is how to implement it? Do I copy it down and incorporate it as a class into my project? Or is there a namespace I can access? Thanks – Haney Apr 2 '18 at 15:45
  • @Haney - I would recommend to spend some time finding another candidate with more community support before committing yourself to unsupported code. Do you have the skills and time to become a maintainer? – Peter M. - stands for Monica Apr 2 '18 at 15:52
  • definitely not - I will explore other options. Thank you! – Haney Apr 2 '18 at 16:04
2

Additionally, is there a better/different way to incorporate Page Objects without using Page Factory?

PageFactory initializes the elements and isn't altogether necessary if you change your defined elements to getters.

This allows you to use a "fluent POM" model if you setup your element to be a property of the page and the page in the "App". App is a class that returns a new instance of the Page (whose constructor is now empty) when one is requested. This also means that you don't have to pass the POM object back and forth since there is not initialization. The element is found when you want to do something with it.

class App {
    HomePage HomePage { return new HomePage(); }
}

class HomePage {
    HomePage HomePage(){ /* empty constructor */ }
    IWebElement MyElement { return new IWebElement(By.Id("foo")); }
}

class Test {
    [Test]
    Example01() {
        App.HomePage.MyElement.Click();
    }
}
  • Note: the empty constructor is not needed. feel free to omit. – kirbycope Oct 8 at 19:55
1

You can use NuGet package which is in two forms, one is called DotNetSeleniumExtras.PageObjects and other one DotNetSeleniumExtras.WaitHelpers.

0

I made a forum post in the Selenium Users google group laying out my preferred POM style that does not use PageFactory. This was not related to the deprecation of PageFactory, but rather personal design choice.
I think this may help you with your situation. If you have to sign up to see it or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.