what disadvantage does it have when creating common method to enter data in a textfield on different applications, is any challenge to identify the text field on different applications? or any peformance issue ?
Thanks,
Beginner
public static int TextBoxClick(Ranorex.Form RanorexFormName, String TextBoxName)
{
int intResult = TextBoxClick(RanorexFormName, TextBoxName, false);
return intResult;
}
public static int TextBoxClick(Ranorex.Form RanorexFormName, String TextBoxName, bool boolHideNotFoundError)
{
/************************************************************************
* Function : TextBoxClick(Ranorex.Form RanorexFormName, String TextBoxName)
*
* Description : This method will search for and (if found)
* : select a TextBox on the form.
*
* Parameters : RanorexFormName - The form object the the TextBox lives on
* : TextBoxName - Name of the TextBox to click
* : boolHideNotFoundError - FALSE (default) - reports that the item was not found - returns -1
* : - TRUE - Hides the error that the item was not found - Still returns -1
* : - This option basically transforms this method into a check if exists method
*
* Return Type : Integer
*
* Return Value : 0 for success, -1 for failure
*
* Revision History
* Date : Author : Reason/Change
* ---------- : ------------------------- : ------------------------------
* 03/05/2009 : Chris Gendreau : Initial Creation
* 12/10/2009 : Chris Gendreau : Added HideNotFoundError option
************************************************************************/
Ranorex.Text HDtext;
int error = 0;
//Search for the Text box on the Form
try
{
RanorexFormName.EnsureVisible();
RanorexFormName.Activate();
Thread.Sleep(500);
HDtext = RanorexFormName.FindSingle(".//text[@controlname='" + TextBoxName + "' or @text='" + TextBoxName + "' or @accessiblename='" + TextBoxName + "']", 30000);
}
catch (RanorexException e)
{
if (boolHideNotFoundError != true)
{
Report.Error("Unable to find TextBox: " + TextBoxName);
Report.Error(e.ToString());
Report.Screenshot();
}
error = -1;
return error;
}
//Click a TextBox
try
{
Report.Debug("Clicking TextBox: " + TextBoxName);
HDtext.Focus();
Thread.Sleep(500);
HDtext.Click(Location.Center);
Report.Debug(" Clicked TextBox: " + TextBoxName);
}
catch (RanorexException e)
{
Report.Error(e.ToString());
Report.Screenshot();
error = -1;
}
return error;
}//End TextBoxClick public void CandQuickChckPhone( string ph1)
{
//Enter phone
repo.LeftNavigation.PrimaryHomePhone.InputTagTxtPhone2_ph1.Click();
Keyboard.Press(ph1);
}
omayer wrote:Thank you Ciege, this is great feedback, would you please add more code example here and there.
Return to Automation Discussions
Users browsing this forum: No registered users and 0 guests