How to reuse browser window among TestMethods in CodedUI?

Below code helps to reuse opened browser:- BrowserWindow driver; [TestMethod] public void CaptureScreenshot() { driver = BrowserWindow.Launch(new System.Uri(“https://www.facebook.com”)); driver.TechnologyName = “Web”; driver.CloseOnPlaybackCleanup = false; driver.Maximized = true; } [TestMethod] public void secondtest() { driver = new BrowserWindow(); driver.SearchProperties.Add(“Title”, “Welcome to Facebook – Log In, Sign Up or Learn More”); HtmlEdit usr = new HtmlEdit(driver); usr.SearchProperties.Add(“Id”,Continue reading “How to reuse browser window among TestMethods in CodedUI?”

How to take screenshots in CodedUI?

Below code will help to take entire screen screenshot- Image MyScreenshot; BrowserWindow driver; [TestMethod] public void CaptureScreenshot() { driver = BrowserWindow.Launch(new System.Uri(“https://www.facebook.com”)); driver.TechnologyName = “Web”; driver.CloseOnPlaybackCleanup = false; driver.Maximized = true; MyScreenshot = driver.CaptureImage(); MyScreenshot.Save(@”D:\Windowscreenshot.png”, System.Drawing.Imaging.ImageFormat.Png); } If we need to take screenshot of any particular UI object then we can use below code- ImageContinue reading “How to take screenshots in CodedUI?”

How to keep the browser open after a CodedUI test finishes?

When we run our first CodedUI test method we notice that system closes the browser after finishing the test method and we just wonder why it closes the browser. So answer is, CodedUI framework has been designed like that only where it closes the browser after finishing the tasks. Same framework has provided an optionContinue reading “How to keep the browser open after a CodedUI test finishes?”