- CSV
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\data.csv", "data#csv", DataAccessMethod.Sequential), DeploymentItem("data.csv"), TestMethod]
- Excel
DataSource("System.Data.Odbc", "Dsn=ExcelFiles;Driver={Microsoft Excel Driver (*.xls)};dbq=|DataDirectory|\\Data.xls;defaultdir=.;driverid=790;maxbuffersize=2048;pagetimeout=5;readonly=true", "Sheet1$", DataAccessMethod.Sequential), DeploymentItem("Sheet1.xls"), TestMethod]
- Test case in Team Foundation Server
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.TestCase", "http://vlm13261329:8080/tfs/DefaultCollection;Agile", "30", DataAccessMethod.Sequential), TestMethod]
- XML
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\data.xml", "Iterations", DataAccessMethod.Sequential), DeploymentItem("data.xml"), TestMethod]
- SQL Express
[DataSource("System.Data.SqlClient", "Data Source=.\\sqlexpress;Initial Catalog=tempdb;Integrated Security=True", "Data", DataAccessMethod.Sequential), TestMethod]
This is a CodedUI blog which serves as a - One stop solution blog for all CodedUI related information. Hope you enjoy this. If anyone has any information it can be shared and also if any improvements can be made please let me know. Few of the topics can be found in other blogs. My main moto is to share knowledge and also collecting the information
Tuesday, 13 December 2016
Data Source Types and Attributes
Thursday, 1 December 2016
How to Click or find control by scrolling page in CodedUI
How to click on control if it is visible on page and we need to scroll the page to click on it.
In CodedUI we have UITestingUtilities dll that helps us a lot in finding control or verifying control existance by providing many extended methods.
In below code sample, we have one button control on page. To click on this control manually, we need to scroll the page and then we can click on control. This can be handled through code by using EnsureClickable() method.
Here we are first making sure that the control exists by using TryFind() method and then trying to click control.
While loop added to check if more page scroll action required. Once the control is clicked the "isClickable" variable set to true, so that to break the While() loop. The exception is thrown if the control is still hidden on blocked by some other control , To handle this condition we have to catch the exception and instead of throwing it we are scrolling the page down.
Code below
BrowserWindow bw = new BrowserWindow();
HtmlButton but = new HtmlButton(bw);
//define properities for the button here
bool isClickable = false;
if(but.TryFind())
{
while (!isClickable)
{
try
{
// It ensures control is visible and clickable
but.EnsureClickable();
Mouse.Click(but);
isClickable = true;
}
catch(FailedToPerformActionOnHiddenControlException)
{
//We dont through an exception instead we scroll the page down and try again
Mouse.MoveScrollWheel(-1);
}
catch (FailedToPerformActionOnBlockedControlException)
{
{
//We dont through an exception instead we scroll the page down and try again
Mouse.MoveScrollWheel(-1);
}
}
}
}
Subscribe to:
Posts (Atom)