You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A feature request based on conversation with @adinapoli in issue #92
Currently all wait* functions use explicit timeout parameters. Instead, include the ability to set a default timeout value as a state variable.
Variation 1: add state field directly to WDConfig and WDSession
conf = defaultConfig
{ explicitWaitTimeout =Just5-- new config field. Nothing indicates indefinite waiting
}
main = runSession conf $do
useWaitTimeout 10-- can also set value via command instead of the config field
waitUntil foo
useIndefiniteWait -- remove timeout. indefinite waiting
waitUntil bar
waitWithTimeoutUntil 10 baz -- explicit timeout value provided. function name too wordy?
Nice and simple with no additional types to work with. Easy to use in situations where test cases are heavily decoupled. However, since the timeout state is "global" to the session it can easily leak into unrelated test cases. Feels like I'm working with an imperative language instead of Haskell, but then again this library is already heavily imperative in design due to the nature of the WebDriver framework.
Variation 2: use a new state monad WDWait on top of WD that keeps track of timeout
In this variation, the wait* combinators result in a WDWait a instead of the current WD a. This new WDWait type is just a state monad on top of the existing WD monad with a simple timeout value.
main = runSession defaultConfig $do
withTimeout 10$do
waitUntil foo
waitUntil bar
withNoTimeout $do-- no timeout. indefinite waiting
waitUntil baz
This results in an block-structured code flow, but might be clunky when test cases are heavily split up or when many different timeouts are desired. Feels more like I'm working with Haskell.
EDIT: On further consideration I don't necessarily think isolated test cases would be clunky. In fact it has a natural-language-esque presentation:
withTimeout 10. waitUntil $...
or
withNoTimeout . waitUntil $...
Questions and Considerations
Should we gut the existing functions that use mandatory timeout arguments, rename them to something else, or keep them as-is and use new names for the new functions? In any of these case, what names should we use?
What is the default for the default? 0? Some arbitrary number of seconds like 5 or 10? Wait indefinitely?
The text was updated successfully, but these errors were encountered:
A feature request based on conversation with @adinapoli in issue #92
Currently all
wait*
functions use explicit timeout parameters. Instead, include the ability to set a default timeout value as a state variable.Variation 1: add state field directly to
WDConfig
andWDSession
Nice and simple with no additional types to work with. Easy to use in situations where test cases are heavily decoupled. However, since the timeout state is "global" to the session it can easily leak into unrelated test cases. Feels like I'm working with an imperative language instead of Haskell, but then again this library is already heavily imperative in design due to the nature of the WebDriver framework.
Variation 2: use a new state monad
WDWait
on top ofWD
that keeps track of timeoutIn this variation, the
wait*
combinators result in aWDWait a
instead of the currentWD a
. This newWDWait
type is just a state monad on top of the existingWD
monad with a simple timeout value.This results in an block-structured code flow, but might be clunky when test cases are heavily split up or when many different timeouts are desired. Feels more like I'm working with Haskell.
EDIT: On further consideration I don't necessarily think isolated test cases would be clunky. In fact it has a natural-language-esque presentation:
or
Questions and Considerations
The text was updated successfully, but these errors were encountered: