lefthandedgoat / canopy

f# web automation and testing library, built on top of Selenium (friendly to c# also)
http://lefthandedgoat.github.io/canopy/
MIT License
507 stars 115 forks source link

Sstop loading page after element is present. #399

Closed uzhas-sovka closed 6 years ago

uzhas-sovka commented 6 years ago

How can I stop loading page after some element is present? In plain Selenium for c# it's possible to set page timeout to 1 sec, receive an error (page continues downloading) and then repeatedly check element presence in catch block.

It seems I can't do this in Canopy, pageTimeout <- 1.0 doesn't give me error.

I'd like something like

pageTimeout <- 1.0
try
  url "some url"
catch
  waitForElement ".number"
  pageTimeout <- 10

Thank you!

lefthandedgoat commented 6 years ago

Can you show me how to set the page timeout in C#?

browser is the IWebDriver and will have all of the same methods, so you should be able to do the same thing.

uzhas-sovka commented 6 years ago
Browser.Manage().Timeouts().PageLoad = new TimeSpan(0, 0, 0, 2);
try
{
  Browser.Navigate().GoToUrl(WPDC.Url);
}
catch (Exception ex1)
{
  something to check presence
}
lefthandedgoat commented 6 years ago
browser.Manage().Timeouts().PageLoad <- System.TimeSpan(0,0,0,2)
try url "http://www.something.com"
with ex -> displayed "selector"

That would be the same thing in canopy

uzhas-sovka commented 6 years ago

Thanks, it works. BTW Canopy is amazing.

lefthandedgoat commented 6 years ago

Awesome!