Dynamic find of hidden control.

4 posts, 0 answers
  1. Chakravarthy
    Chakravarthy avatar
    30 posts
    Member since:
    Jan 2011

    Posted 22 Feb 2011 Link to this post

    Hi Telerik Team,

    We have a sceanrio where we need to identify the Textfield dynamically which is an hidden control, i have used the below code snippet for the same. But it's not working.

    HtmlInputHidden text =  ActiveBrowser.Find.ByExpression<HtmlInputHidden>("id=hidClientId");
    ActiveBrowser.ContentWindow.SetFocus(); 
    Console.WriteLine("Text:"+text); 
    Console.ReadLine();
    text.ScrollToVisible();
    text.Focus();

     

    While i am trying to print the "text" in console, it is not printing any value. Please let me know is this one  correct approcah for hidden controls or is there any other one which is workable.

    Regards,
    Kalyan Uppalapati

  2. Chakravarthy
    Chakravarthy avatar
    30 posts
    Member since:
    Jan 2011

    Posted 24 Feb 2011 Link to this post

    Can you please address the above post.
  3. Chakravarthy
    Chakravarthy avatar
    30 posts
    Member since:
    Jan 2011

    Posted 25 Feb 2011 Link to this post

    Hi Telerik team,

    Please reply to the above post if you have any solution. It's blocking my work to be done.

    Regards,
    Kalyan Uppalapati
  4. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 25 Feb 2011 Link to this post

    Hi Chakravarthy,
        I apologize for the late reply.

    I'm not 100% sure what you're trying to do.
    First off don't use:
    Console.WriteLine("Text:"+text); 
    Console.ReadLine();
    Instead use:
    Log.Writeline();
    This will write directly to the Log file for your test. You will be able to see it when you open the results from your tests.

    Also you don't really need this line:
    ActiveBrowser.ContentWindow.SetFocus();

    I've prepared a little sample test for you. Here's how it looks like in code:
             HtmlInputHidden text = ActiveBrowser.Find.ByExpression<HtmlInputHidden>("NAME=postingID");
             if (text != null)
             {
                 Log.WriteLine("Hidden control value:"+text.Value);
             }
             else { Log.WriteLine("Hidden input couldn't be located"); }
    Just paste this code to a coded step and build the test. The test navigates to http://www.htmlcodetutorial.com/forms/_INPUT_TYPE_HIDDEN.html
    This page contains a hidden control. The test finds this hidden control and the outputs it's value to the Log.
    Run the test and take a look at the log file once it finishes.

    Let me know if you're having trouble getting this to work!

    All the best,
    Stoich
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!