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

9 posts, 1 answers
  1. Sudarshan
    Sudarshan avatar
    22 posts
    Member since:
    Feb 2013

    Posted 26 Feb 2013 Link to this post

    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
  2. Boyan Boev
    Admin
    Boyan Boev avatar
    1043 posts

    Posted 27 Feb 2013 Link to this post

    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
  3. Sudarshan
    Sudarshan avatar
    22 posts
    Member since:
    Feb 2013

    Posted 06 Mar 2013 Link to this post

    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
  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1043 posts

    Posted 07 Mar 2013 Link to this post

    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
  5. Sudarshan
    Sudarshan avatar
    22 posts
    Member since:
    Feb 2013

    Posted 07 Mar 2013 Link to this post

    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
  6. Sudarshan
    Sudarshan avatar
    22 posts
    Member since:
    Feb 2013

    Posted 07 Mar 2013 Link to this post

    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
  7. Answer
    Boyan Boev
    Admin
    Boyan Boev avatar
    1043 posts

    Posted 08 Mar 2013 Link to this post

    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
  8. Sudarshan
    Sudarshan avatar
    22 posts
    Member since:
    Feb 2013

    Posted 11 Mar 2013 Link to this post

    Hi,

    Thanks for the response. It was very helpful.

    Thanks
    Sudarshan
  9. Boyan Boev
    Admin
    Boyan Boev avatar
    1043 posts

    Posted 11 Mar 2013 Link to this post

    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
Back to Top