2011-05-22

iPhone UI Automation and the Page Object pattern

At the time when I was actively contributing to Selenium I used it only in conjunction with FitNesse and could therefore not directly apply the Page Object pattern. However, one of the key principles was for me the abstraction of the UI elements by creating UI maps which contain simple mappings of logical names to XPath path expressions.

The Page Object pattern defines the same abstraction: Define and use UI elements only in one module, and provide only service functions to the test cases.
Instead of diving deeper into theoretical details here is an example:

#import "Common.js"

function LoginView() {
    this.loginCells = window.tableViews()[0].cells();
    this.loginField = this.loginCells["loginFieldCell"].textFields()["loginField"];
    this.passwordField = this.loginCells["passwordFieldCell"].secureTextFields()["passwordField"];
    this.loginButton = this.loginCells["loginButtonCell"].buttons()["loginButton"];

}

LoginView.prototype.login = function(user, password) {
    this.loginField.setValue(user);
    this.passwordField.setValue(password);
    this.loginButton.tap();
}

LoginView.prototype.waitForDisappear = function() {
    this.loginField.waitForInvalid();
}
So a test looks like as follows:

#import "../TestControllers/LoginView.js"
#import "../TestControllers/UserDetailView.js"

var loginView = new LoginView();
var userDetailView;

test("Valid login leads to user detail page", function(t, a) {
    loginView.login("andras_hatvani","password");
    loginView.waitForDisappear();
    userDetailView = new UserDetailView();
    userDetailView.assertUserData("andras_hatvani", "Andras Hatvani");
},options)};

Although I use tuneup_js as test framework in this example, it could be Jasmine or a custom framework.
Important is that I could formulate the tests in a business-like language i.e. in an own DSL, thus it is not only straightforward to write, but also to read. Furthermore, if the UI changes, then I only need to adapt one single unit, namely LoginView.js to make my tests run again.

46 comments:

  1. Nice information about iPhone UI Automation and the Page Object pattern.People willing to get the indepth knowledge in getting framework such as TestNG,jenkins,Maven and POM should get properly get best selenium training in chennai

    ReplyDelete
  2. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.. Selenium Training in Chennai

    ReplyDelete
  3. Excellent explanation about iphone technology., its very interesting to read.. Thanks for sharing such a nice article. Dot Net Training in Chennai | Java Training in Chennai

    ReplyDelete
  4. Nice and good article.. it is very useful for me to learn and understand easily.. thanks for sharing your valuable information and time.. please keep updating.


    Software Testing Training in chennai | Android Training in chennai

    ReplyDelete
  5. Awesome Blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog. Selenium Training Institute in Chennai | ISTQB Training Institute in Chennai | Six Sigma Certification Training in Chennai

    ReplyDelete

  6. Nice blog on Selenium Testing!!! I agree with your points, Testing will help whole organization to handle the projects in efficient manner.

    Selenium Training in chennai |
    selenium training in T Nagar 

    ReplyDelete
  7. I wish to show thanks to you just for bailing me out of this particular trouble.As a result of checking through the net and meeting techniques that were not productive, I thought my life was done.
    java training in bangalore


    ReplyDelete
  8. Wonderful blog. Thanks for sharing this informative blog. Keep updating.
    Final Year Project Center in Chennai | Final Year Project Center in Velachery

    ReplyDelete

  9. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly. 
 Java Training Center in Chennai | Best J2EE Training Center in Chennai | No.1 Java Training Institution in Velachery | Core Java Training in Chennai

    ReplyDelete
  10. Awesome blog, you explain everything in detailed manner, it was very interesting to read. Thanks for sharing such an informative blog. Automation Anywhere Training in Chennai | RPA Training Institute in Chennai | UI Path Training Institute in Chennai

    ReplyDelete
  11. Ciitnoida provides Core and java training institute in

    noida
    . We have a team of experienced Java professionals who help our students learn Java with the help of Live Base Projects. The object-

    oriented, java training in noida , class-based build

    of Java has made it one of most popular programming languages and the demand of professionals with certification in Advance Java training is at an

    all-time high not just in India but foreign countries too.

    By helping our students understand the fundamentals and Advance concepts of Java, we prepare them for a successful programming career. With over 13

    years of sound experience, we have successfully trained hundreds of students in Noida and have been able to turn ourselves into an institute for best

    Java training in Noida.

    java training institute in noida
    java training in noida

    ReplyDelete
  12. Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
    Business Administration Summer Camp in Velachery | Business Administration Summer Classes in Chennai | Business Administration Summer courses in Taramani

    ReplyDelete
  13. Very Useful information that i have found. don't stop and Please keep updating us..... Thanks
    Summer Courses in Perungudi | Summer Courses in OMR | Summer Courses in Velachery

    ReplyDelete
  14. you are posting a good information for people and keep maintain and give more update too.
    Good Summer Courses for Hardware and Networking in Chennai | Perfect Vacation Courses in Chennai

    ReplyDelete
  15. Impressive blog with lovely information. really very useful article for us thanks for sharing such a wonderful blog...
    Summer Camp for Kids in Chennai | Summer courses in Shozhinganallur | Summer classes in Chennai

    ReplyDelete
  16. Impressive blog with lovely information. really very useful article for us thanks for sharing such a wonderful blog... 
    Summer Camp for Kids in Chennai | Summer courses in Shozhinganallur | Summer classes in Chennai

    ReplyDelete
  17. Nice post... Really you are done a wonderful job. Thanks for sharing such wonderful information with us. Please keep on updating... Summer Camp for Computer Science in Velachery | Summer classes for Computer Science in Chennai | Summer Courses for Computer Science in Taramani

    ReplyDelete
  18. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
    Summer Courses for Android in Perungudi | Summer Courses for IOS in Velachery | Summer Courses in OMR

    ReplyDelete
  19. You forgot “Make useful list of topics to write about on your design blog”..
    Best Multimedia Vacation Course in Chennai | No.1 Summer Courses in Porur

    ReplyDelete
  20. Really its a very good article, thanks for taking the time to discuss this, I feel happy about and I love learning more about this topic. Graphic Designing Summer Courses in Velachery | Graphic Designing Summer Courses in Chennai | Graphic Designing Summer Courses in Taramani

    ReplyDelete
  21. Thanks for this grateful information. all this information is very important to all the users and can be used good at all this process.
    Selenium Summer Courses in Velachery | Web designing summer Classes in Adyar | Android summer Courses in OMR

    ReplyDelete
  22. It is a one of the great discussion which is very essential for me as well. I must follow the handy discussion and sure that the content will be very useful to me as well. Keep it up.
    Tata Sky New Connection | Tata Sky DTH | Tata Sky DTH New Connection

    ReplyDelete
  23. I really love reading and following your post as I find them extremely informative and interesting. This post is equally informative as well as interesting.
    ISTQB Certification Training in Chennai | Java Exam Center in Chennai | Microsoft Dot net Certification in Chennai

    ReplyDelete
  24. Great Blog... The information you shared is very effective for learners I have got some important suggestions from it, Keep Sharing such a nice blog.
    UIPath Exam Center in Chennai | Automation Anywhere Exam Center in Chennai | Blue Prism Exam Center in Chennai

    ReplyDelete
  25. Awesome Blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog. Linux Exam Center in Chennai | CCNA Exam Center in Chennai | CCNP Exam Center in Chennai

    ReplyDelete
  26. The best thing is that your blog really informative thanks for your great information!
    Python Certification Training in Chennai | Best Python Coaching in Medavakkam

    ReplyDelete
  27. your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog...
    Comptia N+ Certification Courses in Chennai | No.1 Network+ Classes in Tambaram

    ReplyDelete
  28. Impressive blog with lovely information. Really very useful article for us thanks for sharing such a wonderful blog...
    CompTIA Security+ Certifications Training in Chennai | Best S+ Exams in Taramani

    ReplyDelete
  29. Impressive blog with lovely information. really very useful article for us thanks for sharing such a wonderful blog...
    CompTIA Security Plus Certifications Course in Chennai | Best CompTIA Security+ Training in Mandaveli

    ReplyDelete
  30. Great content thanks for sharing this informative blog which provided me technical information keep posting...
    CompTIA A Plus Certifications Coaching Center in Chennai | No.1 CompTIA Security+ Training in Pallavaram

    ReplyDelete
  31. Excellent information with unique content and it is very useful to know about the information based on blogs...
    Best VMware Training Institute in Chennai | Best VMware Training Institute in Velachery

    ReplyDelete
  32. Good one, Thanks for sharing your views and ideas... it helps to understand clearly... keep rocks...
    VLSI Project Center in Chennai | VLSI Project in Velachery

    ReplyDelete
  33. Very informative post and useful post so happy to read this article share it for everyone.

    Real Time Project Center in Chennai | Real Time Project in Kanchipuram

    ReplyDelete
  34. Great post.Thanks for one marvelous posting! I enjoyed reading it;The information was very useful.
    Big Data Project Center in Chennai | No.1 Big Data Training in Guindy

    ReplyDelete
  35. wow great Article, the details you have provided are much clear, easy to understand.
    NS2 Project Center in Chennai | NS2 Training in Velachery

    ReplyDelete
  36. This is an awesome post. Really very informative and creative contents. These concept is a good way to enhance the knowledge. Java Training in Chennai | Blue prism Training in Chennai

    ReplyDelete
  37. In the beginning, I would like to thank you much about this great post. Its very useful and helpful for anyone looking for tips to help him learn and master in Angularjs. I like your writing style and I hope you will keep doing this good working.
    Best Android Training in Bangalore
    Android Developer Course in Bangalore
    Android App Development Training in Bangalore
    Angularjs Classes in Bangalore
    Angularjs Coaching in Bangalore
    Angularjs Institute in Bangalore

    ReplyDelete
  38. Nice Post. Looking for more updates from you. Thanks for sharing.

    Article submission sites
    Education

    ReplyDelete