puse / machina

Proof-of-concept browser automation toolkit :construction:
Mozilla Public License 2.0
1 stars 0 forks source link

Improve abstractions for various states of views #10

Closed antaranyan closed 1 year ago

antaranyan commented 1 year ago

If there is a valid order of operation, covering it with this kind of tests won't be enough. May be better to provide safe design, e.g. separate functionality for blank and loaded views.

_Originally posted by @antaranyan in https://github.com/despan/machina/pull/9#discussion_r985287182_

antaranyan commented 1 year ago

For example, capabilities of UserProfileView, such as readBio, make sense only for a successfully loaded profile view. Before it's loaded or if it can't be loaded, these would be different interfaces.

For this case, it seems like UserProfileView is a result of an operation that might fail, so having open as an instance method is not convenient. I imagine a better way will be having a top-level structure like TwitterBrowser instance, which will call openUserProfile yielding a UserProfileView in event of success, and UserNotFoundView when it fails.

Might affect the scope of #25 #32

antaranyan commented 1 year ago

As another example, capabilities of UsetTweetsView, such as readNextTweet, don't make much sense if it's not loaded, or the target user is private.

It gets more interesting as (unauthorized) user flow can be interrupted by login dialog.

antaranyan commented 1 year ago

Follow up on #35