Hi,
Can u please let how i can enter text in a text field(webpage), without using PressKeys method.
I want to use this in the code module. Want to set all text at once in text field.
Thanks
Ajay
Enter text in text field without using PressKeys method
-
- Posts: 21
- Joined: Wed Dec 07, 2011 2:54 pm
- Location: India
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Enter text in text field without using PressKeys method
Hi,
you can either add new "Set Value" action to your recording by simply drag/drop the specific repository item into the recording and choosing "Set Value" as action. Or if you are working in code you can use following code snippet:
Tobias
Ranorex Support Team
you can either add new "Set Value" action to your recording by simply drag/drop the specific repository item into the recording and choosing "Set Value" as action. Or if you are working in code you can use following code snippet:
repo.your.InputTag.Element.SetAttributeValue("Value", "yourValue");Regards,
Tobias
Ranorex Support Team
-
- Posts: 21
- Joined: Wed Dec 07, 2011 2:54 pm
- Location: India
Re: Enter text in text field without using PressKeys method
Hi,
I'm unable to work with setattribute method in my code.
Can u please look into my code below and help me with a code snippet.
public void AccessTextBox(string pageName , string textboxName, string textvalue)
{
// Identify a web document by its title
WebDocument TextDocument = "//dom[@caption='" + pageName + "']";
TextDocument.WaitForDocumentLoaded();
Validate.Exists(TextDocument);
TextDocument.WaitForDocumentLoaded();
try
{
IList<Ranorex.InputTag> AllTextTags = TextDocument.FindDescendants<Ranorex.InputTag>();
if(AllTextTags.Count == 0)
foreach(Ranorex.InputTag inputtext in AllTextTags)
{
var TextobjName = inputtext.Name as string;
if (TextobjName != null && TextobjName.ToString() == textboxName )
{
Report.Info("Exists Text Field= " + TextobjName.ToString());
inputtext.Focus();
if (inputtext.Value == "")
{
inputtext.PressKeys(textvalue);
}
else
{
Keyboard.PrepareFocus(inputtext);
Keyboard.Press("{END}{SHIFT DOWN}{HOME}{SHIFT UP}{DELETE}" + textvalue);
}
break;
}
}
}
catch (Exception ex)
{
Report.Error("Error", ex.Message);
}
}
I'm unable to work with setattribute method in my code.
Can u please look into my code below and help me with a code snippet.
public void AccessTextBox(string pageName , string textboxName, string textvalue)
{
// Identify a web document by its title
WebDocument TextDocument = "//dom[@caption='" + pageName + "']";
TextDocument.WaitForDocumentLoaded();
Validate.Exists(TextDocument);
TextDocument.WaitForDocumentLoaded();
try
{
IList<Ranorex.InputTag> AllTextTags = TextDocument.FindDescendants<Ranorex.InputTag>();
if(AllTextTags.Count == 0)
foreach(Ranorex.InputTag inputtext in AllTextTags)
{
var TextobjName = inputtext.Name as string;
if (TextobjName != null && TextobjName.ToString() == textboxName )
{
Report.Info("Exists Text Field= " + TextobjName.ToString());
inputtext.Focus();
if (inputtext.Value == "")
{
inputtext.PressKeys(textvalue);
}
else
{
Keyboard.PrepareFocus(inputtext);
Keyboard.Press("{END}{SHIFT DOWN}{HOME}{SHIFT UP}{DELETE}" + textvalue);
}
break;
}
}
}
catch (Exception ex)
{
Report.Error("Error", ex.Message);
}
}
Re: Enter text in text field without using PressKeys method
I think
Instead of
if (inputtext.Value == "")
{
inputtext.PressKeys(textvalue);
}
u just try
if (inputtext.Value == "")
{
inputtext.value=textvalue;
}
Instead of
if (inputtext.Value == "")
{
inputtext.PressKeys(textvalue);
}
u just try
if (inputtext.Value == "")
{
inputtext.value=textvalue;
}
-
- Posts: 21
- Joined: Wed Dec 07, 2011 2:54 pm
- Location: India
Re: Enter text in text field without using PressKeys method
Thanks for reply, this solved my problem
Ajay
Ajay