-
-
Save KevM/6554377 to your computer and use it in GitHub Desktop.
let on (u: string) = | |
try | |
wait pageTimeout (fun _ -> browser.Url = u) | |
with | |
| ex -> if browser.Url.Contains(u) = false then raise (CanopyOnException(sprintf "on check failed, expected expression '%s' got %s" u browser.Url)); |
I think this will wait for 3 seconds (or whatever pageTimeout is) before trying contains, so for people expecting the original behavior, their tests will run slower.
I guess I thought that was more of an edge case. You'd know better.
I use contains because I typically don't care about the query string stuff.
If your site is better tested with equality I would just override it in canopyExtensions. Make canopy yours =).
I get that I can go my own way. Just hoping to help improve things. My first attempt at fixing it was to remove the query string from the test. What do you think about that. The problem I see is that it breaks compatibility.
Can you give an example. Not sure what would break compatibility.
How about this:
url "http://localhost/path/action?id=1234"
on "http://localhost/path/action?id=1234" //should succeed
on "http://localhost/path/action" //should succeed
on "http://localhost/path/action/subaction" //should fail (currently succeeds)
let on expected =
let url = _browser.Url
if url = expected then true else whackQuerystring(url) = expected
I am suggesting that if the url does not match that on
would whack the query string and compare again.
I see, your suggestion seems totally reasonable
Cool I'll get you a PR when I get a chance sadly my laptop charger is busted so that means Monday.
This will wait for the url to match the expected value then it will backup to use the current behavior which is compare.
My reason for this was I was using
on /base/subpath
to wait for browser to navigate to the page before continuing to test the page. Because the app was currently on/base
there was no waiting.