As you already mentioned, when you try to link to PageFactory.initElements(driver, PageName) , you see the error message as follows:
The name 'PageFactory' does not exist in the current context".
If you look at the documentation for the PageFactory Class API, it clearly states the following:
- System.Object: OpenQA.Selenium.Support.PageObjects.PageFactory
- Namespace: OpenQA.Selenium.Support.PageObjects
Thus, the error basically means that there are some problems installing the Selenium.Support.PageObjects package.
Decision
The correct solution would be to completely remove the Selenium.WebDriver and Selenium.Support.PageObjects packages, and then reinstall them back through NuGet Manager.
Note. Here you can find a similar discussion.
Update
Since you still see the same error, you can make a small change to your code as follows:
Replace:
HomePage homePage = new HomePage(driver); PageFactory.initElements(driver, homePage);
Via:
HomePage homePage = PageFactory.initElements(driver, HomePage);
source share