So utilize MIT I'm going to create a type called complicated page.
Again.
Give me a few minutes to finish implementing the class.
You can go ahead and watch and then of course I'll explain everything after.
So as you can see here I've created the complicated page page object.
Of course it's inheriting from the base page utilizing our object repository pattern created
a complicated page object repository and of course that in here is from the base page
object repository and initializing it with a driver.
Now we just need to implement the other methods.
So next I've implemented the go to method the go to method simply navigates to a new
R-AL the ELSE hard coded which is a bad idea.
But for our purposes it's OK because I'm not focused on these minute little changes that
need to be made to page objects we're focused on the bigger ideas and improving your page
objects for test automation.
So this is the go to method very simple and than I've implemented that is the method and
method again is also very simple where we're checking that the driver you Arel contains
this treeing called complicated page.
Right in the far you Arel contains a string.
Then we are at the right page.
Implement the clicking the first Twitter button.
Let me figure out a locator for this button.
Probably will have to use that's bad because I didn't add any kind of special properties
to these guys.
Awesome.
So utilizing this X path by checking for the title I get back all of the five Twitter buttons.
So if I want to deal with the first one.
Awesome There you go.
So what I have done here and we'll try this out to see if it actually works is I've located
all elements by their X path which equals at title Twitter.
So is going to return me all of the Twitter bunds of which we have five right you guys
can see that here in the developer console that I've ran the sex bath in and returns
me five and we have five Twitter buttons.
And so if I want to click on the first Twitter button I'm just going to get that collection
and then get the first element in that collection.
And that's going to be the first Twitter button.
This is a bad job by me all of these should have IDs but of course I was creating this
page just as a sample for you to practice with so obviously locating them was a bit
more of a pain and a bit more brutal.
But that's not the purpose of the purposes for me to demonstrate how to clean up a complicated
HMO page into a simple page object class.
So I've done that here by finding the first Twitter button so that about wraps up our
test.
We've created the complicated page class that has its own complicated page object repository
the complicated page object repository stores our web element which is called the first
Twitter button.
And then we have two methods inside of our complicated page which does a go to and.
Oh we have three methods I'm sorry it does go to checks that we are at the right page
and then click the first Twitter button.
I'm going to move these to their own files now and then we're going to check the test
to make sure that it works.