Sean Johnson
Sean Johnson

Reputation: 81

How to refresh the browser in a coded ui test

My application is up and running in IE 9 but sometimes not everything loads properly on the page and it causes my coded ui test to fail. So I want to add code to my coded ui test to refresh (F5) the browser when this happens. How can I do this?

Upvotes: 3

Views: 2225

Answers (1)

amurra
amurra

Reputation: 15401

When you launch the web browser it returns an instance of the BrowserWindow object. That BrowserWindow object contains a Rrefresh method you can call:

BrowserWindow currentBrowser = BrowserWindow.Launch(new Uri("https://www.google.com/"));
currentBrowser.Refresh();

You can also call use the Locate method to get an instance of the BrowserWindow you are using if you need to do the refresh in a different place:

BrowserWindow currentBrowser = BrowserWindow.Locate("title of your browser window");
currentBrowser.Refresh();

Upvotes: 1

Related Questions