How to identify Windows ToolBar using CodedUI

Below code will help to click on buttons on tool bar which generally comes when we try to login into the application or try to download any file from the application. As first action we do on the webpage so first we have to identify the webpage and then tool bar which pop-ups after performingContinue reading “How to identify Windows ToolBar using CodedUI”

How to generate logs with CodedUI?

Why logs? Well, it helps to debug the problem in our script. Usually logging and capturing the screenshots are not enable by default with CodedUI and to make it, we need to make some set up. Follow the below steps to enable logging and capturing the screenshots- 1: Go to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDEContinue reading “How to generate logs with CodedUI?”

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?”

How to compare two PDF files with ITextSharp and C#

I have struggled lot to compare two PDF files and display the differences. Finally I came with approach where I am extracting all the text from PDF files, splitting by lines, comparing line by line and showing the differences. So if you have same kind of requirement, you can use below code to resolve it.Continue reading “How to compare two PDF files with ITextSharp and C#”

Cross Browser Testing using CodedUI Test

Before starting this topic I would like to clear in beginning that Visual Studio 2013 uses Selenium WebDriver component to achieve cross browser testing as of now. So to integrate WebDriver component with Visual Studio follow below given steps- Start the Visual Studio and go to Tools menu and click on Extensions and Updates… SystemContinue reading “Cross Browser Testing using CodedUI Test”

How to click on HtmlButton within HtmlCell with CodedUI (C#)

Sometime it’s hard to iterate through HtmlCell and click on Html Button or Radio Button or Check-boxes which is within HtmlCell. In my previous post, I have already described How to get InnerText of HtmlCell and now I am providing sample code to click on HtmlButton. Here we go- public void ClickonButton () { HtmlTable PackageTable =Continue reading “How to click on HtmlButton within HtmlCell with CodedUI (C#)”

How to do Database Testing with CodedUI (C#)?

Here I am providing sample code to start Database Testing with CodedUI (C#)- //Below code willl login and open the DB connection. string connetionString = “Data Source=DBSeverName;Initial Catalog=DBName;User ID=UserName;Password=DBPassword”; SqlConnection connection = new SqlConnection(connetionString); connection.Open(); //Below code will help to execute the Select query. String Selectquery = “Select FirstName from Emp where EmpID in (01)”;Continue reading “How to do Database Testing with CodedUI (C#)?”

How to verify availability of options in a Drop-Down field with CodedUI (C#)

It’s easy to get to know if particular option is available in drop-down field, as we just select that option and it verifies that…OK option is available. However if we want to verify that particular option is not available in some drop-down field then we need to think about some trick. One of trick isContinue reading “How to verify availability of options in a Drop-Down field with CodedUI (C#)”