one of the best ways for UI Mapping.

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

one of the best ways for UI Mapping.

Illusion0Reality
I am trying to create UI Map for objects.

I created one class AllUIMaps- which contains all Page specific sub classes to map objects to make the code understandable. Ofcourse, I can place all page's variables in sequence (by putting comments which fields are related to which page).

 public class AllUIMaps {
          String username ="user_Name";    // This field is on Login page

                        String  userphone="user_phone"  //This field is on Userdetails page
                        String  useraddr="user_addr1"     //This field is on Userdetails page
       }
     }

So, just by creating an instance for the AllUIMaps class, I can access each and every variable. No problem.
But this won't be understandable.


So, I created sub classes wherein one sub/inner class refers to one page in the application.
For login page, I create an inner class LoginPage, and created one varibale "username".
This variable refers to the real html name (in the application) of  that specific edit box.

   public class AllUIMaps {
        class LoginPage
        {
                String username ="user_Name";
        }

     class userDetails{
         userphone="user_phone"
         useraddr="user_addr1"
       }
     }

BUT, the problem is I don't know how to access these variables in a proper way.
Please suggest. I am still thinking.
Reply | Threaded
Open this post in threaded view
|

Re: one of the best ways for UI Mapping.

softwaretestingforum
Administrator
With Selenium 1 (and till of late in Selenium 2) I used different classes for each page to Store UI objects.
Since UI objects are constants I make them static variables hence they could be access using class name with out needing to create instance of class. like -


public class LoginPageUIObject {

private static userName = "input[id = 'name']"
private static userPassword = "input[id = 'password']"

public String getUserName {
return userName;
}

public String getUserPassword {
return userPassword;
}



Now in your test class, you can access them as -

type(LoginPageUIObject.getUserName, "testdata1");
type(LoginPageUIObject.getUserpassword, "testdata2")

.
.
.

Hence you can access UI objects in any class with out instantiating the class LoginPageUIObject.
If you are on Selenium 2 then I would suggest using PageFactory pattern.

Does this help?

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

Re: one of the best ways for UI Mapping.

Illusion0Reality
Yes, this does help!

Curious - You use getter sort of functions. Is this for data/variable protection only, or anything else.
We can also just use the variables (that refer to real properties in the application) directly, instead of using the getter methods. We need to write additional code and put effort for these getter sort of things. Though it has been some convention/tradition in software.


Initially I thought the way that you told. But gave it up later. Using static.

I may arrange them in sub/inner classes wherein every class refers to a specific page.
And, in every class (refers to that page), I will create an object for that specific class, so I can call the methods using that instance

 
Reply | Threaded
Open this post in threaded view
|

Re: one of the best ways for UI Mapping.

softwaretestingforum
Administrator
OOPs says that we should protect data, hence I marked them private. You could also mark them protected but avoid public.
The only trouble I see with "sub/inner classes" is that this might over grow with time and may become difficult to maintain.

But by and large follow, what best suites your needs
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: one of the best ways for UI Mapping.

Illusion0Reality
I agree with you, and my code will grow enormously which could be uncontrollable !

So what is your suggestion, I could not get it clearly. Follow the approach below?
And, I can place them in their respective pages (or page classes). So page1 has all the static variables inside of it. Page2 will have all its static variables inside of it.
 
public class LoginPageUIObject {

private static userName = "input[id = 'name']"
private static userPassword = "input[id = 'password']"

public String getUserName {
return userName;
}

public String getUserPassword {
return userPassword;
}
Reply | Threaded
Open this post in threaded view
|

Re: one of the best ways for UI Mapping.

softwaretestingforum
Administrator
yup I would suggest to create different classes for different pages as you just quoted me -

LoginPageUIObject
ManageProfileUIObject
.
.
.

and keep all of them in a different package. May be name it as UI object.
Let me know if you any confusion.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: one of the best ways for UI Mapping.

Illusion0Reality
Thanks a lot for your help. That improved my knowledge. No confusion at all.

I will again tend to mix your approach with keyword driven technique, because it gives enormous flexibility. And let me know if you could see any drawbacks in this approach and I will correct it.

If there is a function in a specific page (enterUserDetails), and it has 10 fields to be entered in Version1/Release1 .

In later Versions/releases, if the same above function needs to enter some more fields (15 ), then the specific function's code should change.


If this is mixed up with key word driven approach, though initially we have to include all the 15 fields (whatever exists in the application should be put  Case statements), later whenever changes required, by changing the XLS (test data sheet) only, no need to touch the code, we can simply drive the flow by putting the additional test data in the XLS (this can be done even if the person does not know Java).


Any suggestions are most welcome!  






Reply | Threaded
Open this post in threaded view
|

Re: one of the best ways for UI Mapping.

softwaretestingforum
Administrator
Illusion0Reality wrote
If this is mixed up with key word driven approach, though initially we have to include all the 15 fields (whatever exists in the application should be put  Case statements), later whenever changes required, by changing the XLS (test data sheet) only, no need to touch the code, we can simply drive the flow by putting the additional test data in the XLS (this can be done even if the person does not know Java).

I liked this approach. but some how I don't buy the argument of doing it for sake of non technical users. Until unless your client or Business Analyst need it.
In case of form related scenarios. I create different form object classes and my page object methods receive the form object and not the individual data fields. Hence if more fields are added tomorrow I can just modify form object to represent new fields and page object to exercise those new fields. Every thing else remain. I suppose it might not be very clear with my writing and probably I should write a blog post on it.

Also do share your framework approach in detail with us. May be you could write a guest blog here
~ seleniumtests.com