Sunday, 2 December 2012

Mapping web elements

      Guess everyone earlier or later starts thinking about some generic solution for Page Object classes. You may have 50 different elements on your form, and, I hope, you won't create method for each.
What you have to do to initiate mapping?
  • to my regret, define 50 locators 
  • create a "view" class with all bloody fields mentions ( why I call it view class? generally because it regards an html view )
  • put all matching pairs to a map
I advise use of Map<Sting, By> rather than Map<String, WebElement>. Even though you defined your web-elements through page factory, by fact they are getting initiated while populating a map. Ans that slows down iteraction with page due to each elements gets focus.

Negative side is that those elements may be different, or even futhermore, custom - non standard control elements. Then you have to extend "have to" list with elements object layer.

No comments:

Post a Comment