-
-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PageFactory.InitElements Does not work in Net Core as uses a deprecated dll from Net Framework #4387
Comments
I suspected this had been deprecated. Thanks to @p0deje for logging this as I've been hunting for the correct library for the past 20 minutes! |
Has there been any more thought to this issue? |
|
Thanks for the headsup @jimevans , I´ll close the issue if support will not be given. I know that maybe this is not the channel for the question, but there is planned a similar implementation of PageFactory in the future? Again thanks for all your efforts on this project. Being using it for almost 3 years and is a great implementation. 😄 Kind regards, |
@Saetabis1 No. The implementation of PageFactory in .NET does not provide any real benefits in terms of code verbosity over other methods of defining page objects. To be clear, the pattern for deprecation will be as follows:
This will happen over several releases. The first step (deprecation warnings) will happen in the next release of Selenium. The "new repository" will have a big, honking message in the README that says, in effect, "This repository is not maintained, issues will not be fixed, PRs will not be accepted," because that will be true of the new repository. I will not be accepting PRs for that new repo, nor will I be maintaining the code with bug fixes. Consider this an invitation for someone in the community to take over maintenance of that part of the code, once it has been separated out into a new repository, and to feel free to innovate on it there. |
Thanks for the detailed explanation. Kind Regards, |
What should the consumer use instead? |
@AKrasheninnikov The new organization is DotNetSeleniumTools, and the project is DotNetSeleniumExtras. The repository is here, and the first binary releases have been released via NuGet for both PageFactory and ExpectedConditions. |
Thanks, In the simplest possible terms, it goes like this: Install-Package DotNetSeleniumExtras.PageObjects -Version 3.11.0 then using SeleniumExtras.PageObjects; |
@jimevans What is the standard method of defining PageObjects in .Net instead of using the pagefactory ? You say there is no real benefit to using it. Thanks! |
@CurlyFire I'm not going to get into "standard methods" of defining Page Objects. That ventures in to "Best Practices" territory that often yields attempts at a one-size-fits-all solution that may not exist. Having said that, there's no functional difference between the following:
and this:
The two approaches are both lazily loaded, not attempting to find the element until the property is called; both yield the same level of encapsulation that the Page Object Pattern suggests to use; and both will work while adhering to most of the C# style guides that are out there. However, the latter is less verbose and doesn't require complex proxy objects that intercept method calls and act on them. Additionally, I've heard many, many requests over the years for users wanting to define locators in an external file, so they can be changed without recompilation. Though that, too, is of dubious value to me, the latter approach makes it possible; the former does not, as attribute data must be available at compile time. There may be stylistic differences that people don't care for[1], but to keep around a set of code that provides little benefit above stylistic preference that is also complex and difficult to maintain doesn't seem like the best use of the project's limited developer time and attention. [1] Some "stylistic difference" examples: Don't like calling |
@jimevans
and
So the real comparison between PageFactory and another lazy loading way should be: public class MyPage
{
private IWebDriver driver;
[FindsBy(How = How.Id, Using = "foo")]
private IWebElement fooElement;
public MyPage DoBar()
{
fooElement.Click();
return this;
}
} and this: public class MyPage
{
private IWebDriver driver;
private IWebElement fooElement
{
get
{
return driver.FindElement(By.Id("foo"));
}
}
public MyPage DoBar()
{
fooElement.Click();
return this;
}
} In this example the original PageFactory example is less verbose. |
@LirazShay Yes, you’re correct, that’s a far better approximation of a correct implementation of the Page Object Pattern, and completely at odds with most of the Page Object implementations that exist in the wild, in my experience. And that approach still requires a complex system of proxy objects that is difficult to maintain and understand. Further discussion on this issue will not change the decision on the removal of the .NET PageFactory implementation, so I’m going to make this the last word on the subject in this issue report. |
Meta -
OS: Windows 10 Pro
Selenium Version: 3.4.0
Browser: All
Expected Behavior -
PageFactory Init Elements
Actual Behavior -
Warning is raised:
System.TypeLoadException : Could not load type 'System.Runtime.Remoting.Proxies.RealProxy' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. at OpenQA.Selenium.Support.PageObjects.DefaultPageObjectMemberDecorator.CreateProxyObject(Type memberType, IElementLocator locator, IEnumerable1 bys, Boolean cache) at OpenQA.Selenium.Support.PageObjects.DefaultPageObjectMemberDecorator.Decorate(MemberInfo member, IElementLocator locator) at OpenQA.Selenium.Support.PageObjects.PageFactory.InitElements(Object page, IElementLocator locator, IPageObjectMemberDecorator decorator)
Error is raised
OneTimeSetUp: System.TypeLoadException : Could not load type 'System.Runtime.Remoting.Proxies.RealProxy' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c5 61934e089'.
Steps to reproduce -
Possible solution
https://github.com/dotnet/corefx/issues/4091
https://github.com/dotnet/corefx/tree/master/src/System.Reflection.DispatchProxy .
Kind Regards,
Saetabis.
The text was updated successfully, but these errors were encountered: