by akommalapati » Tue Dec 20, 2011 2:05 pm
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);
}
}