Searching for text
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Searching for text
TIA - Dave
Got the findallchildren logic working, but still seems cludgey
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Paul,
Ok, do you have any problems with the code you posted?
Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have three TABS but these three tabs are in one Cell, now i want to click on different tabs ar per need basis, one way is to hard code the position of each tab which i dont want to do, other way is to search the Text and click it, but as i mentioned these tabs are in one Cell i am unable to write down a routine which can search the text inside the cell and click on it. I have tried page.FindChild("innerText","Text",100), page.FindChild("NativeWebObject.innerText","text",100) but nothing worked.
Thanks for your help!
Muhammad Mazhar Mahmood
Certified Software Tester (CSTE)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Muhammad,
Please post here the HTML code of this cell. You can get it via its 'outerHTML' parameter.
BTW, please note that you can call the 'FindChild' method of the cell object. This will work faster and more reliable.
Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, code is a little bit lengthy so i have posted zip file too. I want to click on the words highlighted in bold.
<TD align=left><?IMPORT NAMESPACE = TSNS IMPLEMENTATION = "http://ae001vm0131/webctrl_client/1_0/tabstrip.htc" DECLARENAMESPACE /><TSNS:TabStrip id=tbsBudget onSelectedIndexChange="JScript:document.frmBudgetGrid.__tbsBudget_State__.value=event.index;if (getAttribute('_submitting') != 'true'){setAttribute('_submitting','true');try{__doPostBack('tbsBudget','');}catch(e){setAttribute('_submitting','false');}}" selectedIndex="0" onwcready="JScript:try{document.frmBudgetGrid.__tbsBudget_State__.value=selectedIndex}catch(e){}" tabSelectedStyle="color:#FFFFFF;background-color:#7A95C0;border-bottom:none font-family: MS Sans Serif, Verdana;text-align:center;" tabHoverStyle="color:#000000;background-color:#D8E7F5;border-color:#7A95C0;border-width:1px;border-style:Solid;font-weight:bold;font-family:MS Sans Serif, Verdana;font-size:11px;height:21;width:79;text-align:center;" tabDefaultStyle="color:#000000;background-color:#D8E7F5;border-color:#7A95C0;border-width:1px;border-style:Solid;font-weight:bold;font-family:MS Sans Serif, Verdana;font-size:11px;height:21;width:79;text-align:center;" targetID="mlpBudget">
<TSNS:Tab>PL </TSNS:Tab>
<TSNS:Tab>EN </TSNS:Tab>
<TSNS:Tab>CON </TSNS:Tab>
</TSNS:TabStrip><?IMPORT NAMESPACE = MPNS IMPLEMENTATION = "http://ae001vm0131/webctrl_client/1_0/multipage.htc" DECLARENAMESPACE /><MPNS:MultiPage id=mlpBudget onSelectedIndexChange="JScript:document.frmBudgetGrid.__mlpBudget_State__.value=event.selectedIndex" selectedIndex="0" selectedIndex = "0"><MPNS:PageView style="DISPLAY: block">
<SCRIPT language=javascript>
var g_varSelectedTxt=0;
/*******************************************************************************
Function Name : SetSelectedTxt
Author : Raj
Purpose : Gets the value of the selected textbox and stores it in
a global variable
*******************************************************************************/
function SetSelectedTxt(p_varSelectedTxt)
{
if(ContainsCharacter(p_varSelectedTxt)&& p_varSelectedTxt!="#")
{
g_varSelectedTxt="#";
}
else if((!isNaN(p_varSelectedTxt)) && p_varSelectedTxt<0)
{
g_varSelectedTxt="#";
}
else
{
g_varSelectedTxt=p_varSelectedTxt;
}
}
/*******************************************************************************
Function Name : ContainsCharacter
Author : Raj
Purpose : Checks whether the input parameter contains atleast one
character returns true if it finds a character
else returns false
*******************************************************************************/
function ContainsCharacter(p_strValue)
{
var intChar=0;
var chChar="";
for(intChar=0;intChar<p_strValue.length;intChar++)
{
chChar=p_strValue.charAt(intChar);
if(isNaN(chChar)||chChar==' ')
{
return true;
}
}
return false;
}
/*******************************************************************************
Function Name : CalculateSum
Author : Raj
Purpose : Calculates the sum of values present in textboxes in
each row and column and displays the result in the
appropriate textboxes
*******************************************************************************/
function CalculateSum(p_strErrorMessage, p_objSelTxtBox, p_objColTolTxtBox, p_objRowTolTxtBox, p_objGrdTolTxtBox,p_objRHSRowTolTxtBox,p_objRHSGrdTolTxtBox,p_objErrorMsg, p_objDownColTolTxtBox, p_objDownGrdTolTxtBox,p_objDownRHSGrdTolTxtBox )//Changed 3/11
{
var intColTol=0;
var intRowTol=0;
var intGrdTol=0;
var intOldValue=0;
var intRowSum=0;
var intGrdSum=0;
var intColSum=0;
var intNewValue=parseInt(p_objSelTxtBox.value,10);
var strTxt=p_objSelTxtBox.value;
var blContainsChar= ContainsCharacter(strTxt);
//p_objErrorMsg.innerText="";
if(( blContainsChar && strTxt!='#') || (parseInt(strTxt,10)<0) || strTxt=="" )
{
intNewValue=0;
/* p_objErrorMsg.innerText=p_strErrorMessage;
p_objSelTxtBox.value=g_varSelectedTxt;
p_objSelTxtBox.focus();
return false;*/
}
if(strTxt=='#')
{
intNewValue=0;
}
intColTol=parseInt(p_objColTolTxtBox.value,10);
intRowTol=parseInt(p_objRowTolTxtBox.value,10);
intGrdTol=parseInt(p_objGrdTolTxtBox.value,10);
intOldValue=parseInt(g_varSelectedTxt,10)
if(isNaN(intColTol)) intColTol=0;
if(isNaN(intRowTol)) intRowTol=0;
if(isNaN(intGrdTol)) intGrdTol=0;
if(isNaN(intOldValue)) intOldValue=0;
intRowSum=intRowTol+intNewValue-intOldValue;
intColSum=intColTol+intNewValue-intOldValue;
intGrdSum=intGrdTol+intNewValue-intOldValue;
if(isNaN(intRowSum)) intRowSum=0;
if(isNaN(intColSum)) intColSum=0;
if(isNaN(intGrdSum)) intGrdSum=0;
p_objRowTolTxtBox.value=intRowSum;
p_objRHSRowTolTxtBox.value=intRowSum;
p_objColTolTxtBox.value=intColSum;
p_objDownColTolTxtBox.value=intColSum;
p_objGrdTolTxtBox.value=intGrdSum;
p_objRHSGrdTolTxtBox.value=intGrdSum;
p_objDownGrdTolTxtBox.value=intGrdSum;
p_objDownRHSGrdTolTxtBox.value=intGrdSum;
if(!isNaN(strTxt))
{
if(strTxt!="" && ContainsCharacter(strTxt)==false)
{
p_objSelTxtBox.value=parseInt(strTxt,10);
}
}
}
</SCRIPT>
<TABLE class=borderblue cellSpacing=1 cellPadding=0 border=0>
<TBODY>
<TR>
<TD class=header colSpan=6>
<DIV align=left> 000001 > PL</DIV></TD></TR>
<TR>
<TD class=header align=middle rowSpan=2> DBS </TD>
<TD class=header colSpan=4>
<DIV align=center>WBS</DIV></TD>
<TD class=header align=middle rowSpan=2> DBS </TD></TR>
<TR>
<TD class=header vAlign=center align=middle>Total</TD>
<TD class=header vAlign=center align=left>AREA1 <SPAN class=txtwhitelink><A class=txtwhitelink tabIndex=-1 href="javascript:showModalDialog('../P3400/S3400_20_Popup.htm?AID=AMS3400_10_WBS&XBSID=15736',null,'dialogWidth:516px;dialogHeight:216px;help:no;center:yes;status:no;edge:raised;scroll:0');"><SPAN class=i>i</SPAN></A></SPAN></TD>
<TD class=header vAlign=center align=left>AREA2 <SPAN class=txtwhitelink><A class=txtwhitelink tabIndex=-1 href="javascript:showModalDialog('../P3400/S3400_20_Popup.htm?AID=AMS3400_10_WBS&XBSID=15737',null,'dialogWidth:516px;dialogHeight:216px;help:no;center:yes;status:no;edge:raised;scroll:0');"><SPAN class=i>i</SPAN></A></SPAN></TD>
<TD class=header vAlign=center align=middle>Total</TD></TR>
<TR class=datarow>
<TD class=header vAlign=center align=middle>Total</TD>
<TD class=totaldata vAlign=center align=right><INPUT class=totalfield id=ucrMainBudget_txt1_1 tabIndex=-1 readOnly size=12 value=0 name=ucrMainBudget:txt1_1></TD>
<TD class=totaldata vAlign=center align=right><INPUT class=totalfield id=ucrMainBudget_txt2_1 tabIndex=-1 readOnly size=12 value=0 name=ucrMainBudget:txt2_1></TD>
<TD class=totaldata vAlign=center align=right><INPUT class=totalfield id=ucrMainBudget_txt3_1 tabIndex=-1 readOnly size=12 value=0 name=ucrMainBudget:txt3_1></TD>
<TD class=totaldata vAlign=center align=right><INPUT class=totalfield id=ucrMainBudget_txt4_1 tabIndex=-1 readOnly size=12 value=0 name=ucrMainBudget:txt4_1></TD>
<TD class=header vAlign=center align=middle>Total</TD></TR>
<TR>
<TD class=bgmediumdarkblue vAlign=center align=left> <SPAN class=txtwhite>CV </SPAN><SPAN class=txtwhitelink><A class=txtwhitelink tabIndex=-1 href="javascript:showModalDialog('../P3400/S3400_20_Popup.htm?AID=AMS3400_10_DBS&XBSID=23143',null,'dialogWidth:516px;dialogHeight:216px;help:no;center:yes;status:no;edge:raised;scroll:0');"><SPAN class=i>i</SPAN></A></SPAN></TD>
<TD class=totaldata vAlign=center align=right><INPUT class=totalfield id=ucrMainBudget_txt1_2 tabIndex=-1 readOnly size=12 value=0 name=ucrMainBudget:txt1_2></TD>
<TD class=datarow vAlign=center align=right maxlength="10"><INPUT class=datarowtotalfield id=ucrMainBudget_txt2_2 onfocus="return SetSelectedTxt(value);" readOnly maxLength=6 onchange="return CalculateSum('Please enter valid budget value',this, ucrMainBudget_txt2_1, ucrMainBudget_txt1_2, ucrMainBudget_txt1_1, ucrMainBudget_txt4_2, ucrMainBudget_txt4_1, lblErrorMsg, ucrMainBudget_txt2_3, ucrMainBudget_txt1_3, ucrMainBudget_txt4_3);" size=10 value=# name=ucrMainBudget:txt2_2></TD>
<TD class=datarow vAlign=center align=right maxlength="10"><INPUT class=datarowtotalfield id=ucrMainBudget_txt3_2 onfocus="return SetSelectedTxt(value);" readOnly maxLength=6 onchange="return CalculateSum('Please enter valid budget value',this, ucrMainBudget_txt3_1, ucrMainBudget_txt1_2, ucrMainBudget_txt1_1, ucrMainBudget_txt4_2, ucrMainBudget_txt4_1, lblErrorMsg, ucrMainBudget_txt3_3, ucrMainBudget_txt1_3, ucrMainBudget_txt4_3);" size=10 value=# name=ucrMainBudget:txt3_2></TD>
<TD class=totaldata vAlign=center align=right><INPUT class=totalfield id=ucrMainBudget_txt4_2 tabIndex=-1 readOnly size=12 value=0 name=ucrMainBudget:txt4_2></TD>
<TD class=bgmediumdarkblue vAlign=center align=left> <SPAN class=txtwhite>CV </SPAN><SPAN class=txtwhitelink><A class=txtwhitelink tabIndex=-1 href="javascript:showModalDialog('../P3400/S3400_20_Popup.htm?AID=AMS3400_10_DBS&XBSID=23143',null,'dialogWidth:516px;dialogHeight:216px;help:no;center:yes;status:no;edge:raised;scroll:0');"><SPAN class=i>i</SPAN></A></SPAN></TD></TR>
<TR class=datarow>
<TD class=header vAlign=center align=middle>Total</TD>
<TD class=totaldata vAlign=center align=right><INPUT class=totalfield id=ucrMainBudget_txt1_3 tabIndex=-1 readOnly size=12 value=0 name=ucrMainBudget:txt1_3></TD>
<TD class=totaldata vAlign=center align=right><INPUT class=totalfield id=ucrMainBudget_txt2_3 tabIndex=-1 readOnly size=12 value=0 name=ucrMainBudget:txt2_3></TD>
<TD class=totaldata vAlign=center align=right><INPUT class=totalfield id=ucrMainBudget_txt3_3 tabIndex=-1 readOnly size=12 value=0 name=ucrMainBudget:txt3_3></TD>
<TD class=totaldata vAlign=center align=right><INPUT class=totalfield id=ucrMainBudget_txt4_3 tabIndex=-1 readOnly size=12 value=0 name=ucrMainBudget:txt4_3></TD>
<TD class=header vAlign=center align=middle>Total</TD></TR>
<TR>
<TD class=header align=middle rowSpan=2> DBS </TD>
<TD class=header style="WIDTH: 100px" vAlign=center align=middle>Total</TD>
<TD class=header style="WIDTH: 100px" vAlign=center align=left>AREA1 <SPAN class=txtwhitelink><A class=txtwhitelink tabIndex=-1 href="javascript:showModalDialog('../P3400/S3400_20_Popup.htm?AID=AMS3400_10_WBS&XBSID=15736',null,'dialogWidth:516px;dialogHeight:216px;help:no;center:yes;status:no;edge:raised;scroll:0');"><SPAN class=i>i</SPAN></A></SPAN></TD>
<TD class=header style="WIDTH: 100px" vAlign=center align=left>AREA2 <SPAN class=txtwhitelink><A class=txtwhitelink tabIndex=-1 href="javascript:showModalDialog('../P3400/S3400_20_Popup.htm?AID=AMS3400_10_WBS&XBSID=15737',null,'dialogWidth:516px;dialogHeight:216px;help:no;center:yes;status:no;edge:raised;scroll:0');"><SPAN class=i>i</SPAN></A></SPAN></TD>
<TD class=header style="WIDTH: 100px" vAlign=center align=middle>Total</TD>
<TD class=header align=middle rowSpan=2> DBS </TD></TR>
<TR>
<TD class=header colSpan=4>
<DIV align=center>WBS</DIV></TD></TR></TBODY></TABLE></MPNS:PageView></MPNS:MultiPage></TD>
Muhammad Mazhar Mahmood
Certified Software Tester (CSTE)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Muhammad,
Thanks for sending the code. If you look at the code of the objects you need to work with, you will see that there are extra spaces that must be taken into account when searching for an object:
<TSNS:Tab>PL </TSNS:Tab>
<TSNS:Tab>EN </TSNS:Tab>
<TSNS:Tab>CON </TSNS:Tab>
You can do this by replacing the extra spaces with the wildcard character:
var obj = page.FindChild("innerText","EN*",100);
obj.Click();
Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Muhammad Mazhar Mahmood
Certified Software Tester (CSTE)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Muhammad,
I am guessing that you sent the server-side code of the page. TestComplete works with the client-side version of the application, so could you please send me the client-side HTML code? You can get it by executing this code in TestComplete:
var obj = page.FindChild("NativeWebObject.id", "tbsBudget", 100);
Log.Message("See HTML in Remarks", obj.outerHTML);
Please send me the HTML code posted to the Remarks pane.
Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Getting "You are trying to call the "outerHTML" method or property of an object that does not exist."
Regards!
Muhammad Mazhar Mahmood
Certified Software Tester (CSTE)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Muhammad,
Did you open the tested page in Internet Explorer and assign the Page object to the 'page' variable before executing the code? If you did, save the HTML code of the entire page and send it as a separate file. You can use the following code:
;
Log.Message("See HTML in Remarks", htmlObj.outerHTML);
Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am attaching two OuterHTML codes, one of the Cell Object and One of the Panel/Page object.
Actually that Cell don't have any ID so when getting OuterHTML by specifying any condition it gives Object Not Found Error, however i have recorded the steps and then call your suggested routine to get the OuterHTML for that cell/object.
Secondly Page does not have the OuterHTML property, all the objects are under a Panel so i have posted Panel OuterHTML.
Regards!
Muhammad Mazhar Mahmood
Certified Software Tester (CSTE)
