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

Dynamic find of hidden control.

3 Answers 61 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chakravarthy
Top achievements
Rank 1
Chakravarthy asked on 22 Feb 2011, 01:57 PM

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

3 Answers, 1 is accepted

Sort by
0
Chakravarthy
Top achievements
Rank 1
answered on 24 Feb 2011, 07:54 AM
Can you please address the above post.
0
Chakravarthy
Top achievements
Rank 1
answered on 25 Feb 2011, 06:26 AM
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
0
Stoich
Telerik team
answered on 25 Feb 2011, 12:38 PM
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!
Tags
General Discussions
Asked by
Chakravarthy
Top achievements
Rank 1
Answers by
Chakravarthy
Top achievements
Rank 1
Stoich
Telerik team
Share this question
or