Skip to content

Instantly share code, notes, and snippets.

@KevM
Forked from lefthandedgoat/gist:6554142
Created September 13, 2013 18:35
Show Gist options
  • Save KevM/6554377 to your computer and use it in GitHub Desktop.
Save KevM/6554377 to your computer and use it in GitHub Desktop.
**on** equals vs. contains compromise?
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));
@lefthandedgoat
Copy link

Can you give an example. Not sure what would break compatibility.

@KevM
Copy link
Author

KevM commented Sep 13, 2013

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.

@lefthandedgoat
Copy link

I see, your suggestion seems totally reasonable

@KevM
Copy link
Author

KevM commented Sep 14, 2013

Cool I'll get you a PR when I get a chance sadly my laptop charger is busted so that means Monday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment