Introduction:
Using this WaTin feature user would be able to get all the controls types dynamically used in web page.
Details:
Let me give an example to explain this with clear picture.
Suppose that developer has placed a table on webpage. This table would contents many controls like textbox, button, picture box, label, dropdown, list etc. etc. all this control would appear in table cells dynamically, it means we are not sure when and at what position of cells it will appear in table.
Now we have to read this control on fly and performed some basic operation.
So being an automation engineer, we have programmed our automation code in such a way to know about this control and where it has appeared then performed operation or read properties of that control.
Its bit tricky to handle this kind of situation.
To solve this kind of issues WaTin have provided one best feature to get the type of controls and then based on control we can call our custom method to either get the properties or performed common action.
Here I will only show to how to read controls types on FLY using WaTin.
Below is the Image of web page (to automate this scenario I have developed one basic web application)
try
{
IE ie = IE.AttachTo<IE>(Find.ByUrl("http://localhost:28348/Home.aspx"));
var tablecells = ie.Table("table").TableCells;
var type = new string[tablecells.Count];
int i = 0;
foreach (TableCell tableCell in tablecells)
{
try
{
string watinType = tableCell.Elements[0].GetType().FullName;
if (watinType != null) type[i] = watinType.Split('.')[2];
}
catch (Exception)
{
throw;
}
i++;
}
}
Catch (Exception)
{
throw;
}
Thanks,
Md. Jawed
Using this WaTin feature user would be able to get all the controls types dynamically used in web page.
Details:
While performing automation so many times we have faced the issues to find the control type on fly and perform some basic operation or get the properties of controls.
Let me give an example to explain this with clear picture.
Suppose that developer has placed a table on webpage. This table would contents many controls like textbox, button, picture box, label, dropdown, list etc. etc. all this control would appear in table cells dynamically, it means we are not sure when and at what position of cells it will appear in table.
Now we have to read this control on fly and performed some basic operation.
So being an automation engineer, we have programmed our automation code in such a way to know about this control and where it has appeared then performed operation or read properties of that control.
Its bit tricky to handle this kind of situation.
To solve this kind of issues WaTin have provided one best feature to get the type of controls and then based on control we can call our custom method to either get the properties or performed common action.
Here I will only show to how to read controls types on FLY using WaTin.
Below is the Image of web page (to automate this scenario I have developed one basic web application)
And here is the piece of the code to the same.
try
{
IE ie = IE.AttachTo<IE>(Find.ByUrl("http://localhost:28348/Home.aspx"));
var tablecells = ie.Table("table").TableCells;
var type = new string[tablecells.Count];
int i = 0;
foreach (TableCell tableCell in tablecells)
{
try
{
string watinType = tableCell.Elements[0].GetType().FullName;
if (watinType != null) type[i] = watinType.Split('.')[2];
}
catch (Exception)
{
throw;
}
i++;
}
}
Catch (Exception)
{
throw;
}
And below is the Result when you run the above piece of code. You can see all the controls type in the Type array of string. Shown in below drop down.
Feel free to provide your valuable comments and suggestion.
Thanks,
Md. Jawed
No comments:
Post a Comment