I'm creating a test automation framework in c#. At the top of the project I have "using OpenQA.Selenium.Support.PageObjects;", however when I try to reference PageFactory.initElements(driver, PageName) I'm seeing the message "The name 'PageFactory' does not exist in the current context".
I thought the PageFactory class was included as part of the Selenium.Support nu get package. Tutorials online seem to reference the PageFactory in the same way I am with no extra imports, is there anything I'm missing?
NuGet packages:
Code below:
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.PageObjects;
using System;
using System.IO;
namespace Framework.TestCases
{
class TestCase
{
[Test]
public void Test()
{
String pathToDrivers = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\Drivers";
IWebDriver driver = new ChromeDriver(pathToDrivers);
String searchTerm = "Search Term";
driver.Url = "https://website.com/";
driver.Manage().Window.Maximize();
HomePage homePage = new HomePage(driver);
PageFactory.initElements(driver, homePage);
}
}
}
If anyone faces the same issue, please install from NuGet package manager the following:
DotNetSeleniumExtras.PageObjects.Core (3.12.0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With