cancel
Showing results for 
Search instead for 
Did you mean: 

How do you wait on a Window?

Occasional Contributor

How do you wait on a Window?

For the web portion in test left, you can IWebPage.Wait, but there is no equivalent for an ITopLevelWindow. I'm trying out TestLeft to see if it fits our needs, and the first test is to test the login functionality. Enter username, password, click login and wait for the MainWindow to open. But the test runs through without waiting for the authentication call.

 

1 REPLY 1
Moderator

Re: How do you wait on a Window?

Hi la2texas,

 

You can use TryFind to search and wait for objects:

// Wait for the Notepad window for 25 seconds
ITopLevelWindow wndNotepad; process.TryFind<ITopLevelWindow>(new WindowPattern() { WndClass = "Notepad" }, 1 /* depth */, 25000 /* ms timeout */, out wndNotepad);
if (wndNotepad != null)
{ // found
}

There are TryFind overloads with and without explicit timeout. If the timeout is not specified, the default timeout of 10 seconds is used (it is controlled by the Driver.Options.General.AutoWaitTimeout value).


Helen Kosova
SmartBear Technical Writer
________________________
Join the annual community event and share your stories to win gifts
Wintertainment2019