I am trying to create a simple Selenium script to login to a page directly proceeded by logging out from the page. I am using Selenium with C# and PageFactory to reach the elements on the webpage.
I am able to login to the page, but unable to logout. The login and logout button themselves are made visible by clicking the loginLogoutElementMakeVisible element seen below. This element changes after logging in.
My current solution is to have one reference to the element in my code as seen below:
public IWebElement loginLogoutElementMakeVisible
Html for the button to make login button visible:
Html for the button to make logout button visible:
The general concept I have used is to have these two action methods in the page object to login and logout.
I have also tried creating two separate fieldmember WebElements (e.g. one loginElementMakeVisible and one logoutElementMakeVisible) for the button to display the login and the logout button, but still having them in the same page object and thus initializing them at the same time (Thought this could work since pagefactory uses lazy loading)
I have also tried to have the logout button in another pageobject which is initialized after login in the test.
Is there a way to make the pagefactory update its proxy to the loginLogoutElementMakeVisible so I can logout? Or am I still trying to logout before the page after logging has had a chance to load? Are there other problems which could explain why I cannot click the MakeVisible element?