Question on Page Objects

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Question on Page Objects

krampra
I have a test case where I do not know what the next page will be until I click on login button.
 
Scenario
1. Enter email address and password
2. click Login
3. In next page it will prompt for passphrase (if the passphrase is not expired). If the passphrase is expired, it will display expired passphrase page and I have to click on change passphrase and change it.
 
so here I have 3 conditions-
1. invalid login- I will stay in login page
2. Valid login- but expired passphrase- i will be in Expired passphrase page
3. Valid login- and if passphrase is not expired- I will be prompted for passphrase
 
How can I implement page object in this case?
 
Reply | Threaded
Open this post in threaded view
|

Re: Question on Page Objects

softwaretestingforum
Administrator
Write 3 methods for three different conditions and each of the method would return corresponding page object -

public LoginPage invalidLogin() {
// Invalid login steps
return this;
}


public ExpiredPassPhrasePage loginWithExpiredPassPhrase() {
// Login steps with expired passphrase
return new ExpiredPassPhrase(driver);
}

public PassPhrasePage loginWithValidCredentials {
// Valid login steps
return new PassPhrasePage(driver);
}

Hope this helps
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Question on Page Objects

krampra
Thanks very much for the reply. I still have a qn on the implementation. Apologize if it is not a valid qn..
 
But which page object method should I be calling from test method?
Eg: Assuming if the passphrase is not expired and if I call "loginWithValidCredentials" expecting it to return it will return "PassPhrasePage ". But I will be getting "ExpiredPassPhrasePage".
 
So I should be doing an assertion in the test method after calling each method from a page object to make sure it is on the right page? and if it is not on the right page I should call the next method?
 
Thanks!
Karthik

On Mon, Mar 25, 2013 at 10:30 PM, tarunkumar [via Manual and Automated Testing] <[hidden email]> wrote:
Write 3 methods for three different conditions and each of the method would return corresponding page object -

public LoginPage invalidLogin() {
// Invalid login steps
return this;
}


public ExpiredPassPhrasePage loginWithExpiredPassPhrase() {
// Login steps with expired passphrase
return new ExpiredPassPhrase(driver);
}

public PassPhrasePage loginWithValidCredentials {
// Valid login steps
return new PassPhrasePage(driver);
}

Hope this helps


If you reply to this email, your message will be added to the discussion below:
http://manual-and-automated-testing.1070.n6.nabble.com/Question-on-Page-Objects-tp5001706p5001707.html
To unsubscribe from Question on Page Objects, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Question on Page Objects

softwaretestingforum
Administrator
My assumption was that you would know in advance which method is to be invoked.
If not then it is going to be tedious
~ seleniumtests.com