Avatar of paulpp
paulppFlag for United States of America

asked on 

IE Automation - search source code for string

Hello,

I am trying to do a test whether a string on a webpage.  The problem is the text is encoded into a javascript function, so I cant do GetElementsBy....  Below is the source code I am looking at (I just attached the script the string is in), and a snipet of the line containg the string i need ("Parts not found !!".  Thank you.
str = str + "  <td class=\"LT_dataR\"><font color=red>Parts not found !!</font><a href='javascript:beforeOpenAlter(0);' onbeforeactivate='JAVASCRIPT:ignoreChange(true);'><img src='/gspn/images/en/Icon_search.gif' border=0 hspace=2 align='absmiddle'></a></td>";
      str = str + "</tr>";

Open in new window

function displayListData(){
    var str = "   <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"LT_deco\" id="+tid+">";
      str = str + "    <tr>";
      str = str + "     <td width=\"5%\" class=\"LT_head\"><input type=checkbox name=chk_all onClick=checkAll();></td>";
      str = str + "     <td width=\"12%\" class=\"LT_head\">Parts No <font color=#FF6600>*</font></td>";
      str = str + "     <td width=\"7%\" class=\"LT_head\">Qty <font color=#FF6600>*</font></td>";
 
      str = str + "     <td width=\"12%\" class=\"LT_head\">Shipping Method <font color=#FF6600>*</font></td>";
 
      str = str + "     <td width=\"12%\" class=\"LT_head\">Narda/Ticket No</td>";
 
      str = str + "     <td width=\"11%\" class=\"LT_head\">Service Date</td>";
      str = str + "     <td width=\"12%\" class=\"LT_head\">Reason</td>";
 
      str = str + "     <td class=\"LT_headR\">Result</td>";
      str = str + "    </tr>";
 
      str = str + "<tr>";
      str = str + "  <td align=center class=\"LT_data\"><input type=\"checkbox\" name=\"chk\"></td>";
 
      str = str + "  <td class=\"LT_data\"><input name=\"material\" type=\"text\" class=\"Fdefaultp\" size=20 maxlength=18 value=\"TEST\" onKeyUp=\"checkPartNo(this, "+0+")\" onChange=\"onChangePart(this)\"><a href=\"javascript:beforeOpen("+0+");\" onbeforeactivate=\"JAVASCRIPT:ignoreChange(true);\"><img src=\"/gspn/images/en/Icon_search.gif\" border=\"0\" hspace=\"2\" align=\"absmiddle\"></a></td>";
      str = str + "  <td class=\"LT_data\"><input name=\"quantity\" type=\"text\" class=\"F100p\" maxlength=6  style=\"text-align:right;\" value=\"14\" onChange=\"checknum(this);\"></td>";
 
 
 
 
      //str = str + "<td class=\"LT_data\"><input name=\"ship_method0\" type=\"radio\" class=\"FDefault\" value=\"S\" >Standard";
      //str = str + "<input name=\"ship_method0\" type=\"radio\" class=\"FDefault\" value=\"E\" >Expedited";
	  //str = str + "<input name=\"ship_method0\" type=\"radio\" class=\"FDefault\" value=\"N\" >No Cool</td><input type=hidden name=ship_method value=\"D1\">";
      str = str + "<td class=\"LT_data\"><select name=\"ship_method\" class=\"F70p\" style=\"width:100%\">";
                str = str + "<option value=\"\"></option>";
 
                str = str + "<option value=\"D8\" >Next Day</option>";
 
                str = str + "<option value=\"T1\" >2ND Day</option>";
 
                str = str + "<option value=\"D1\"  selected >Ground</option>";
 
                str = str + "</select></td>";
 
      str = str + "  <td class=\"LT_data\"><input name=\"refno\" type=\"text\" class=\"F100\" maxlength=10 value=\"\" ></td>";
 
      str = str + "  <td class=\"LT_data\"><input name=\"service_date\" value=\"\" type=\"text\" class=\"Fdefault\" style=\"text-align:left;ime-mode:disabled\" size=8 maxlength=10 onkeydown=\"checkDateFormat(this, window.event.keyCode,'down','MM/dd/yyyy')\" onkeyup=\"checkDateFormat(this, window.event.keyCode,'up','MM/dd/yyyy')\"><img src=\"/gspn/images/en/Icon_cal.gif\" hspace=\"2\" border=\"0\" align=\"absmiddle\" onclick=\"javascript:beforeOpenCalendar('FORM_ORDER.service_date', "+0+");\" style=\"cursor:hand;\"></td>";
      str = str + "  <td class=\"LT_data\"><input name=\"reason\" type=\"text\" class=\"F100\" maxlength=50 value=\"\" ></td>";
 
      str = str + "  <td class=\"LT_dataR\"><font color=red>Parts not found !!</font><a href='javascript:beforeOpenAlter(0);' onbeforeactivate='JAVASCRIPT:ignoreChange(true);'><img src='/gspn/images/en/Icon_search.gif' border=0 hspace=2 align='absmiddle'></a></td>";
      str = str + "</tr>";
 
      str = str + "</table>";
 
    document.all.sortDIV.innerHTML = str;
  }

Open in new window

Microsoft ExcelVisual Basic.NET

Avatar of undefined
Last Comment
paulpp
Avatar of hes
hes
Flag of United States of America image

Can you try something like

Dim blnComp As Boolean
Dim strHtml As String
Dim sPos As Long

'Navigate to the site
Web1.Navigate2 TargetUrl
      blnComp = False
      Do Until blnComp = True And Web1.Busy = False
         DoEvents
      Loop
'find the start and end points you are looking for
      sPos = InStr(strHtml, "Parts not found !!")
      If sPos <> 0 then
          ' found it
       End If

Private Sub Web1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
   blnComp = True
End Sub
Avatar of paulpp
paulpp
Flag of United States of America image

ASKER

Hello hes,

I am a little confused.  Once I get the source code into a string I will have no problem finding if the string exists.  I am looking on how exactly to either:

1.  Get the source code to stream into a variable
2.  Download the source code to a text file and then use a streamreader to assign it to a variable.

Hope that clears it up.  If I am reading your suggestion incorrectly I appologize, please let me know where strHTML string is getting filled.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of paulpp
paulpp
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Glad that you got it sorted :-)
Avatar of paulpp
paulpp
Flag of United States of America image

ASKER

The answer that worked for me is in my post, but Codecruiser helped me get there.
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo