Warning: fopen(/tmp/SghXTngBZPli-7wvLar.tmp): failed to open stream: Disk quota exceeded in /home/executea/public_html/blog/wp-admin/includes/class-wp-filesystem-ftpext.php on line 139
Warning: unlink(/tmp/SghXTngBZPli-7wvLar.tmp): No such file or directory in /home/executea/public_html/blog/wp-admin/includes/class-wp-filesystem-ftpext.php on line 142
In the last post, we discussed record and playback of web application using Coded UI Test, in this part we will try to hand code the application as did in Hand coding of windows application.
In this post we will again try to re-insist the “Parent Child” relationship of controls such as Browser Window, HtmlDocument and HtmlControls. So let discuss the complete hand coding in the video shown below
Here is the complete code for the above video discussed
public void CustomWebMethod()
{
//Create the Browser Window
BrowserWindow broWin = new BrowserWindow();
broWin.SearchProperties[BrowserWindow.PropertyNames.Name] = "Execute Automation";
HtmlDocument doc = new HtmlDocument(broWin);
doc.FilterProperties[HtmlDocument.PropertyNames.Title] = "Execute Automation";
HtmlEdit txtUserName = new HtmlEdit(doc);
txtUserName.SearchProperties[HtmlEdit.PropertyNames.Name] = "UserName";
Keyboard.SendKeys(txtUserName, "Karthik");
HtmlInputButton btnLogin = new HtmlInputButton(doc);
btnLogin.SearchProperties[HtmlInputButton.PropertyNames.Name] = "Login";
Mouse.Click(btnLogin);
broWin = new BrowserWindow();
broWin.SearchProperties[UITestControl.PropertyNames.Name] = "Execute Automation";
doc = new HtmlDocument(broWin);
doc.FilterProperties[HtmlDocument.PropertyNames.Title] = "Execute Automation";
System.Threading.Thread.Sleep(4000);
HtmlEdit txtInitial = new HtmlEdit(doc);
txtInitial.SearchProperties[HtmlEdit.PropertyNames.Name] = "Initial";
Keyboard.SendKeys(txtInitial, "KK");
}
Thanks for watching the video and reading the blog !!!
Please leave your comments and let me know if there is anything I need to improve in this article and video !!!
Thanks,
Karthik KK
Post Author:
Karthik kk
25 Replies to “Hand Coding Web Application using Coded UI Test”
When will Coded In Builder be part of the normal tools?
What is exact difference between Search properties and Filter Properties? which is better and faster for identify the control according to the coding standards which one is more preferable to use?
Hi,
can anyone help me out how to automate by hand coding in coded ui to test a web application by hovering menu items and then clicking the sub menu under them
HI karthick,
I have a web application which has a number of Html Custom menu items (capable of being recognized by coded ui) but has a number of submenus too some of which are HtmlCustom controls and some as HtmlHyperlink controls. These sub menu items are hidden . My aim is to hover over the menu items (i.e html custom control)and then when they get expanded to click on the sub menu items which act as hyperlink. I am not able to do this. i use this code for clicking all the hyperlink .help me out how to handle with the HtmlCustom and then click items below it.
hi karthick,
let me explain you brief so it might give you some idea to help me out
1)I launch the url
2)i extracted all the hyperlinks from the web page
3)It extracted all the links including main menu which involves only in hovering and then go to sub menu for clicking event which acts as hyperlinks
issue which i undergone is the browser is cannot able to identify those main menu so i cannot able to click other hyperlinks further in sub menu.
My aim is to hover over the menu items (i.e html custom control)and then when they get expanded to click on the sub menu items which act as hyperlink. I am not able to do this. i use this code for clicking all the hyperlink .help me out how to handle with the HtmlCustom and then click items below it.
foreach (UITestControl links in collection)
{
HtmlHyperlink hyperlink = (HtmlHyperlink)links;
string h = hyperlink.Href.ToString();
// To generate code for this test, select “Generate Code for Coded UI Test” from the shortcut menu and select one of the menu items.
Console.WriteLine(h);
}
give me ideas for further action to be proceeded that will be helpfull for me, and show me some sample code for hovering over main menu and then clicking the sub menu hyperlinks.
hi karthick,
let me explain you brief so it might give you some idea to help me out
1)I launch the url
2)i extracted all the hyperlinks from the web page
3)It extracted all the links including main menu which involves only in hovering and then go to sub menu for clicking event which acts as hyperlinks
issue which i undergone is the browser is cannot able to identify those main menu so i cannot able to click other hyperlinks further in sub menu.
My aim is to hover over the menu items (i.e html custom control)and then when they get expanded to click on the sub menu items which act as hyperlink. I am not able to do this. i use this code for clicking all the hyperlink .help me out how to handle with the HtmlCustom and then click items below it.
foreach (UITestControl links in collection)
{
HtmlHyperlink hyperlink = (HtmlHyperlink)links;
string h = hyperlink.Href.ToString();
// To generate code for this test, select “Generate Code for Coded UI Test” from the shortcut menu and select one of the menu items.
Console.WriteLine(h);
}
give me ideas for further action to be proceeded that will be helpfull for me, and show me some sample code for hovering over main menu and then clicking the sub menu hyperlinks.
Hi Karthick,
Really thanks for your response and suggest me after you are trying it, so that it will be helpfull for me.if any one could help me then suggest me your ideas
If i am launching a browser with an url and adding new tab to the same browser how to pass another url to the new tab..its technology name is MSAA and control type is client how to handle with it
Hi Karthik,
I was wondering that if you knew of a good book that can help us out understanding the Microsoft errors and something that has the methods. Ex: You knew about the SendKeys method but as a beginner I had no idea about it. So if the book can also have the methods listed out that would be useful :)!! And these tutorials are fantastic, better than every other tutorial out there
Hi Karthik,
I have another question. Instead of using the Keyboard.SendKeys method and hard coding a value for initials, is there a way where we can dynamically pause the code the during runtime and the user enters the initials. And then the code continues on ?
My question is how to access the data from csv file in other methods, i.e., other than test method . Instead of hardcoding the data can we access through the csv file to “CustomWebMethod()”?.
My question is, can we send the data without hard coding using CSV file for other methods than the test method?i.e., can i send the data though csv for CustomWebMethod()?
When will Coded In Builder be part of the normal tools?
It wont be I think, since it comes as a part of Visual Studio Ultimate edition only !!!
Hi Karthik,
What is exact difference between Search properties and Filter Properties? which is better and faster for identify the control according to the coding standards which one is more preferable to use?
Thanks
Anudeep
Hi,
can anyone help me out how to automate by hand coding in coded ui to test a web application by hovering menu items and then clicking the sub menu under them
help me out with this issue
I have not tried this personally though, but will this help ?
https://msdn.microsoft.com/en-us/library/dd286726.aspx#VerifyingCodeUsingCUITGenerateAssertions
HI karthick,
I have a web application which has a number of Html Custom menu items (capable of being recognized by coded ui) but has a number of submenus too some of which are HtmlCustom controls and some as HtmlHyperlink controls. These sub menu items are hidden . My aim is to hover over the menu items (i.e html custom control)and then when they get expanded to click on the sub menu items which act as hyperlink. I am not able to do this. i use this code for clicking all the hyperlink .help me out how to handle with the HtmlCustom and then click items below it.
hi karthick,
let me explain you brief so it might give you some idea to help me out
1)I launch the url
2)i extracted all the hyperlinks from the web page
3)It extracted all the links including main menu which involves only in hovering and then go to sub menu for clicking event which acts as hyperlinks
issue which i undergone is the browser is cannot able to identify those main menu so i cannot able to click other hyperlinks further in sub menu.
My aim is to hover over the menu items (i.e html custom control)and then when they get expanded to click on the sub menu items which act as hyperlink. I am not able to do this. i use this code for clicking all the hyperlink .help me out how to handle with the HtmlCustom and then click items below it.
HtmlControl controls = new HtmlControl(browser);
controls.SearchProperties.Add(HtmlControl.PropertyNames.ClassName, “HtmlHyperlink”);
UITestControlCollection collection = controls.FindMatchingControls();
foreach (UITestControl links in collection)
{
HtmlHyperlink hyperlink = (HtmlHyperlink)links;
string h = hyperlink.Href.ToString();
// To generate code for this test, select “Generate Code for Coded UI Test” from the shortcut menu and select one of the menu items.
Console.WriteLine(h);
}
give me ideas for further action to be proceeded that will be helpfull for me, and show me some sample code for hovering over main menu and then clicking the sub menu hyperlinks.
Regards,
suruthi.s
hi karthick,
let me explain you brief so it might give you some idea to help me out
1)I launch the url
2)i extracted all the hyperlinks from the web page
3)It extracted all the links including main menu which involves only in hovering and then go to sub menu for clicking event which acts as hyperlinks
issue which i undergone is the browser is cannot able to identify those main menu so i cannot able to click other hyperlinks further in sub menu.
My aim is to hover over the menu items (i.e html custom control)and then when they get expanded to click on the sub menu items which act as hyperlink. I am not able to do this. i use this code for clicking all the hyperlink .help me out how to handle with the HtmlCustom and then click items below it.
HtmlControl controls = new HtmlControl(browser);
controls.SearchProperties.Add(HtmlControl.PropertyNames.ClassName, “HtmlHyperlink”);
UITestControlCollection collection = controls.FindMatchingControls();
foreach (UITestControl links in collection)
{
HtmlHyperlink hyperlink = (HtmlHyperlink)links;
string h = hyperlink.Href.ToString();
// To generate code for this test, select “Generate Code for Coded UI Test” from the shortcut menu and select one of the menu items.
Console.WriteLine(h);
}
give me ideas for further action to be proceeded that will be helpfull for me, and show me some sample code for hovering over main menu and then clicking the sub menu hyperlinks.
Got it !!!
The reason is because the submenus will be rendered in page only while you hover, since they may be a Javascript to display the UL or LI.
Well, hovering I have not did personally, but let me do it and see if I could achieve it.
If not its open to community to respond your query as well, Any thoughts guys ?
Thanks,
Karthik KK
Hi Karthick,
Really thanks for your response and suggest me after you are trying it, so that it will be helpfull for me.if any one could help me then suggest me your ideas
Thanks,
Suruthi.S
hi,
how to extract the value or innertext by using html span
Using GetProperty(“innerText”)
i cant loacte the exact html spane it takes the previous button
Hi,
If i am launching a browser with an url and adding new tab to the same browser how to pass another url to the new tab..its technology name is MSAA and control type is client how to handle with it
Hi,
can anyone help me out how to check the performance or speed for loading a webpage links simaltanious using coded ui c# hand coding
can you post tutorial for Coded UI Web Performance & Load Testing? Awaiting your response.
Hi Karthik,
I was wondering that if you knew of a good book that can help us out understanding the Microsoft errors and something that has the methods. Ex: You knew about the SendKeys method but as a beginner I had no idea about it. So if the book can also have the methods listed out that would be useful :)!! And these tutorials are fantastic, better than every other tutorial out there
Thanks for your comments Ashjeet !
There are no documentation as such, but you can drill down the API for more information.
Thanks,
Karthik KK
Hi Karthik,
I have another question. Instead of using the Keyboard.SendKeys method and hard coding a value for initials, is there a way where we can dynamically pause the code the during runtime and the user enters the initials. And then the code continues on ?
I dont think so
Hi Karthik ,
My question is how to access the data from csv file in other methods, i.e., other than test method . Instead of hardcoding the data can we access through the csv file to “CustomWebMethod()”?.
Hi Karthik,
My question is, can we send the data without hard coding using CSV file for other methods than the test method?i.e., can i send the data though csv for CustomWebMethod()?
HtmlInputButton btnLogin = new HtmlInputButton(doc);
btnLogin.SearchProperties[HtmlInputButton.PropertyNames.Name] = “Login”;
Mouse.Click(btnLogin)
I get an error message when I debug test (The playback failed to find the control with the given search properties)
Please advise.
I guess you can add additional search properties to identify the control.
Thanks,
Karthik KK