This is a migrated thread and some comments may be shown as answers.

How to set text in Forms that appears on clicking a button in a website

8 Answers 101 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sudarshan
Top achievements
Rank 2
Sudarshan asked on 27 Feb 2013, 03:04 AM
Hi

For example, there is a button Add details in a website, which on clicking opens a dialog or form or popup. How to access fields present in that newly opened window, how to set text and click buttons present in the newly opened window?

Thanks
Sudarshan

8 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 27 Feb 2013, 08:55 AM
Hi Sudarshan,

See below for complete sample code against a public site with a popup child window:

  
//Turn on new browser tracking before the popup link is clicked
Manager.SetNewBrowserTracking(true);
  
Find.ByTagIndex<HtmlAnchor>("a", 58).Click();
Manager.WaitForNewBrowserConnect("http://www.htmlcodetutorial.com/linking/popup_test_a.html", true, 5000);
  
//You can now turn off new browser tracking
Manager.SetNewBrowserTracking(false);

//Check whether the ActiveBrowser is now the popup.
Assert.IsTrue(ActiveBrowser.Url.Contains(
"http://www.htmlcodetutorial.com/linking/popup_test_a.html"));      
             
//Here implement the code against the popup i.e. find elements, type text, press button.
             
ActiveBrowser.Close();
  
          
Assert.IsTrue(ActiveBrowser.Url.Contains("http://www.htmlcodetutorial.com/linking/linking_famsupp_70.html"));
 
Hope this helps.

Kind regards,
Boyan Boev
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Sudarshan
Top achievements
Rank 2
answered on 06 Mar 2013, 10:26 AM
Hi,

I tried it. But dint work. On clicking the button, a form is getting opened. I'm not able to access the fields present in that form.

For example: 
There is a button ADD Details in the application and on clicking it opens a form that has fields Name, DOB, Email,Save Button, Cancel Button.
i need to fill the Details in the form and click save. How to do it?  
Thanks
Sudarshan
0
Boyan Boev
Telerik team
answered on 07 Mar 2013, 03:14 PM
Hi Sudarshan,

This code should work without any problems. I recorded a video in which we are opening a pop up and taking some actions against it.

In order for us to reproduce the exact behavior, we may require some additional information and resources to better understand what exactly is happening in your scenario.

- Doing so would require that we either obtain direct access to your application or attempt to "simulate" an identical environment through a Fiddler trace. The latter option would require that you capture this trace by manually reenacting the same 'workflow' that would bring you to this part of your application (where the dialog occurs) in your test and attach it to this support ticket in a zip file. If you are unfamiliar with how to do so, this link will provide you with step-by-step instructions for download and use.

-  Can you please record a Jing video demonstrating the entire process, so we can better understand what is happening?

- Please send us the log of execution.

Hope to hear from you soon.

All the best,
Boyan Boev
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Sudarshan
Top achievements
Rank 2
answered on 07 Mar 2013, 04:27 PM
Hi,

I got it. I had to use another Manager to handle the popups. I'm using webaii.framework in my project which has manager defined in that, so to handle that popup i had to use another manager settings and disable it once done with the popup.

Thanks
Sudarshan
0
Sudarshan
Top achievements
Rank 2
answered on 07 Mar 2013, 04:44 PM
Hi,

there is a dropdown list in the application. I'm using HTMLSELECT to access that and to select an option i'm using setbyvalue property to select an option in the dropdown. When i do that, the value that i specify in my code is getting displayed in the dropdownlist but the contents of the selected value are not getting changed.

For Example: in the dropdownlist if there are many options to be selected like India, australia, US, Uk etc and if UK is the default one and if it has some contents showing in the web page and when i change to India its changing in the dropdown but the contents with respect to India are not getting displayed. Its still showing the contents of default one ie UK contents.

I'm using this in my code.

HTMLSELECT selectcountry = find.byid<htmlselect>("countrydropdownlist");
selectcountry.setbyvalue("252");

Thanks
Sudarshan
0
Accepted
Boyan Boev
Telerik team
answered on 08 Mar 2013, 01:37 PM
Hi Sudarshan,

Most probably selecting the value in the dropdown should trigger some Javascript event which calls the other content. You need to trigger it manually:

selectcountry.AsjQueryControl().InvokejQueryEvent(ArtOfTest.WebAii.jQuery.jQueryControl.jQueryControlEvents.change);

This code will trigger the jQuery onChange event of the dropdown. 

Please change this line of code according to your needs (i.e. change the element and the event if needed).

Please read more about how to trigger jQuery events in code. 

Hope this helps.

Greetings,
Boyan Boev
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Sudarshan
Top achievements
Rank 2
answered on 11 Mar 2013, 05:22 AM
Hi,

Thanks for the response. It was very helpful.

Thanks
Sudarshan
0
Boyan Boev
Telerik team
answered on 11 Mar 2013, 10:32 AM
Hi Sudarshan,

Glad to hear it!

Please contact us again if you have further questions. 

Kind regards,
Boyan Boev
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Sudarshan
Top achievements
Rank 2
Answers by
Boyan Boev
Telerik team
Sudarshan
Top achievements
Rank 2
Share this question
or