ExecuteAutomation

Exploring features of Browser in CUIT

In this post, we will discuss working with different advanced features of browserwindow class in Coded UI Testing.Using BrowserWindow class of Coded UI testing we can perform some of the most common and useful operations such as

Working with Existing browser session

There are many situations were, we might need to work with existing opened browsers, this can be done very easily using Locate() method available with BrowserWindow class of coded UI Testing.
NoteIn Selenium WebDriver, working with existing session is not possible till now, which is still a feature request by many but still in vein, which you can read from here. But the same is possible with RemoteWebDriver and that too supports only FireFox browser !!!
Here is the code snippet
BrowserWindow window = BrowserWindow.Locate("Execute Automation");

Clearing Cache and Cookies of browser

We can clear cache and cookies of browser before launching the browser using the following code snippet
BrowserWindow.ClearCookies();
BrowserWindow.ClearCache();

Capturing Screenshot of the browser

We can capture the screenshot of the browser as well using the code snippet below
  Image image = window.CaptureImage();
  image.Save(@"D:\captured.jpeg", ImageFormat.Jpeg);
  image.Dispose();

Other useful properties of BrowserWindow class

We can also user CurrentBrowser property of BrowserWindow class to set the browser we are working, this can be helpful while working with cross browser testing to enable working with different browsers like Firefox and Chrome. You can watch the complete video from the video below Thanks for watching the video and reading the article !!! Please leave your comments and let me know if there is anything need to be improved in the article. Thanks, Karthik KK