简体   繁体   中英

Are there any examples of creating and implementing an Interface in a Selenium based Test Automation Framework?

I have personally always used just abstract classes in my framework. But have never personally created an Interface to implement in my Test Automation Framework.

But there has to be some instances where people have created an Interface to work with in their Selenium based Test Automation Framework.

I am looking for such examples where this applies.

For example, let's say, you are given a basic website with two pages to test. How will you create and use an Interface in your Test Automation Framework?

I am using Java as the language of choice. I know what an interface is but I want to know how or when can I create an Interface for my Test Automation Framework. It is currently Page Object Model based.

I don't have code to show as an example, but I did once design a framework that I was going to implement that took advantage of the features of using interfaces.

We had an Appium project for an application that had two flavors, essentially, of the same app. The difference was in the branding - colors and names, and it affected the code in that while the page layouts were identical, the locators were different because of the identifiers containing the branded names.

Using a page object model, you cannot dynamically change a locator, so the solution was to define an interface and then create a page object for each application, each with its own locators, but obviously all the same methods.

Therefore, a flag would determine which application you were using, and when you'd instantiate a page object, you could have it define the page object using the interface thereby merging the page objects in a way so that it was transparent to the test app, the methods were still the same.

I hope I'm being clear, and I'm going by memory since as I said, I had designed and tested this whole thing out, and it worked great, but the powers that be (at that time) decided to not use that method. It was actually just a proof-of-concept project anyway, so I guess it didn't really matter, but had it been implemented, it would have made it easier down the road to add more branded versions without having to change a lot, if any, of the test code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM