I'm having an issue with sharing my driver between step files in my projects. I've done a lot of googling online and come up with a solution using the IObjectContainer. Which I believe is correct? However, it doesn't seem to work. It gets stuck. I don't quite understand where IObjectContainer gets instantiated. Below is the code of my Hooks file and one of my Step Files:
Hooks File:
public class RDM_Hooks
{
private IObjectContainer _objectContainer;
public RDM_Website<ChromeDriver> RDM_Website;
public void WebDriverSupport(IObjectContainer objectContainer)
{
_objectContainer = objectContainer;
}
[BeforeScenario]
public void InitWebDriver()
{
RDM_Website = new RDM_Website<ChromeDriver>();
_objectContainer.RegisterInstanceAs<RDM_Website<ChromeDriver>>(RDM_Website);
}
[AfterScenario]
public void DisposeWebDriver()
{
RDM_Website.SeleniumDriver.Quit();
RDM_Website.SeleniumDriver.Dispose();
}
}
Steps File:
public class RDM_LoginSteps
{
private RDM_Website<ChromeDriver> RDM_Website;
public RDM_LoginSteps(RDM_Website<ChromeDriver> rdm_website)
{
RDM_Website = rdm_website;
}
[Given(@"I am on the homepage")]
public void GivenIAmOnTheHomepage()
{
RDM_Website.RDM_Homepage.VisitHomePage();
}
}
I think im missing something somewhere but any info i've found online doesn't go further than the above and I'm a bit lost.
I simply want all my step files to share the same browser so I'm able to have all my login steps using one file and do something else on another for example.