what is wrong with my code for invoking a javascript
-
Thursday, February 16, 2012 8:14 PM
I am trying to automate downloading pdf documents from a third party web page.
the jscript seciton of the webpage is something like this:
<SCRIPT language=javascript type=text/javascript> function ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_popViewDocPStmnt(indxCnt){ var hidRowCounter = document.getElementById("ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter"); var hidRowCounter_nth = document.getElementById("ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter"+indxCnt); hidRowCounter.value = hidRowCounter_nth.value; if (false){ document.OpenDocForm1.submit(); } else { document.OpenDocForm2.submit(); } } </SCRIPT> the input section html for downloading the PDF doc's is like this <TBODY class=contentframework-stripedtable> <TR> <TH class=contentframework-dataheadertop width="100%" scope=col> <DIV id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_anchorToFocusPStmt1 tabIndex=-1 name="ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_anchorToFocusPStmt1"><STRONG>Statements for Customer </STRONG></DIV></TH></TR> <TR class=" contentframework-altrow contentframework-altrow contentframework-altrow"> <TH class=contentframework-dataheadertop width="100%" scope=col><STRONG>Statement Date </STRONG></TH></TR> <TR> <TD width="100%"><A title="(opens PDF in new window)" href="javascript:ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_popViewDocPStmnt(1);">29 December 2006 - 31 January 2007 <IMG alt="(opens PDF in new window)" src="/uos/common/images/icons/pdf.gif"> </A><INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter1 value=0 type=hidden name=RowCounter1> </TD></TR> <TR class=" contentframework-altrow contentframework-altrow contentframework-altrow"> <TD width="100%"><A title="(opens PDF in new window)" href="javascript:ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_popViewDocPStmnt(2);">30 November 2006 - 29 December 2006 <IMG alt="(opens PDF in new window)" src="/uos/common/images/icons/pdf.gif"> </A><INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter2 value=1 type=hidden name=RowCounter2> </TD></TR> <TR> <TD width="100%"><A title="(opens PDF in new window)" href="javascript:ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_popViewDocPStmnt(3);">31 October 2006 - 30 November 2006 <IMG alt="(opens PDF in new window)" src="/uos/common/images/icons/pdf.gif"> </A><INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter3 value=2 type=hidden name=RowCounter3> </TD></TR> <TR class=" contentframework-altrow contentframework-altrow contentframework-altrow"> <TD width="100%"><A title="(opens PDF in new window)" href="javascript:ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_popViewDocPStmnt(4);">29 September 2006 - 31 October 2006 <IMG alt="(opens PDF in new window)" src="/uos/common/images/icons/pdf.gif"> </A><INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter4 value=3 type=hidden name=RowCounter4> </TD></TR> <TR> <TD width="100%"><A title="(opens PDF in new window)" href="javascript:ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_popViewDocPStmnt(5);">31 August 2006 - 29 September 2006 <IMG alt="(opens PDF in new window)" src="/uos/common/images/icons/pdf.gif"> </A><INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter5 value=4 type=hidden name=RowCounter5> </TD></TR> <TR class=" contentframework-altrow contentframework-altrow contentframework-altrow"> <TD width="100%"><A title="(opens PDF in new window)" href="javascript:ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_popViewDocPStmnt(6);">31 July 2006 - 31 August 2006 <IMG alt="(opens PDF in new window)" src="/uos/common/images/icons/pdf.gif"> </A><INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter6 value=5 type=hidden name=RowCounter6> </TD></TR> <TR> <TD width="100%"><A title="(opens PDF in new window)" href="javascript:ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_popViewDocPStmnt(7);">30 June 2006 - 31 July 2006 <IMG alt="(opens PDF in new window)" src="/uos/common/images/icons/pdf.gif"> </A><INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter7 value=6 type=hidden name=RowCounter7> </TD></TR> <TR class=" contentframework-altrow contentframework-altrow contentframework-altrow"> <TD width="100%"><A title="(opens PDF in new window)" href="javascript:ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_popViewDocPStmnt(8);">31 May 2006 - 30 June 2006 <IMG alt="(opens PDF in new window)" src="/uos/common/images/icons/pdf.gif"> </A><INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter8 value=7 type=hidden name=RowCounter8> </TD></TR> <TR> <TD width="100%"><A title="(opens PDF in new window)" href="javascript:ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_popViewDocPStmnt(9);">28 April 2006 - 31 May 2006 <IMG alt="(opens PDF in new window)" src="/uos/common/images/icons/pdf.gif"> </A><INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter9 value=8 type=hidden name=RowCounter9> </TD></TR> <TR class=" contentframework-altrow contentframework-altrow contentframework-altrow"> <TD width="100%"><A title="(opens PDF in new window)" href="javascript:ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_popViewDocPStmnt(10);">31 March 2006 - 28 April 2006 <IMG alt="(opens PDF in new window)" src="/uos/common/images/icons/pdf.gif"> </A><INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter10 value=9 type=hidden name=RowCounter10> </TD></TR></TBODY></TABLE> <TABLE border=0 width="100%"> <TBODY>
so in my .net c# app, I parsed and obtain a string array sReslt of
scriptname, the argument ( row # between parentheses)
and for each row I tried to
object[] arg = new object[1]; arg[0] = sReslt[i, 1]; string scriptNm = sReslt[i, 0]; object o = wbctl.getActiveBrowser().Document.InvokeScript(scriptNm, arg);
the resulting object is null and I only get a response windows to save or open for the last one on the list
what can I do to fix the problem?
adding line after the invokescript with thread sleep does not help
All Replies
-
Friday, February 17, 2012 6:21 AMModeratorHi,
Your resources are fragmented that we could not get your point.
The control in the following is not given in your html code:
var hidRowCounter = document.getElementById("ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter");
And some other staffs are not available too, like OpenDocForm1, OpenDocForm2, etc.
From your description about the C# logics at the end of your original post, I could not get any point on what you are trying to implement.
Thanks for your understanding.
Have a nice day,Leo Liu [MSFT]
MSDN Community Support | Feedback to us
-
Saturday, February 18, 2012 4:44 AM
all I want is to simulate clicking the each row that will result in downloading and let me enter the required responses. ( ultimately the complete code should automatcally make available proper file name in clipboard for me to paste into the saving as file windows that will popup, but that is not the problem at the moment)
the problem now is some how only the last one will show up for me to save
there is no room for complete HTML,
I was just illustrating the main point of interest. the complete html is rather long.
here is some of the missing html
<DIV id=pagetitlearea class=clear> <H1 id=pagetitle>View and Manage Documents </H1></DIV> <FORM id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_openDocForm2 method=post name=OpenDocForm2 action=/wps/myportal/OLB/!ut/p/c5/pdDRboIwGAXgZ_EBlr9aBuOyWlxxWBhQoNwYwjoGUSDOofL04rKLxUR2sf6XX85JTiGF4eqsK4vsUDZ1toUEUn3j2i-6bWqIoZVGke1YmBFrOV0s8eDyl7vTq5vMxO6ji58R_kcazfU_0jEkSNsE1VO7Ph8Sp190YdUHiFPSr_t8xvcKce55b5Ev5mQuhZxth0w61mrgUdds48ZvFtPZuCM86t-br47uPIIgUPVmQYCzZqdAQmrcHRPpEP580bE9mwk_Udl4OTmdTR57lElehKue-SIiwqRxJSZDnxzti_fqs_na5wr8plV1VKojvOZZ_qEc1amtlxUK2p0QXWv51juZPkgyuQCt4YTn/><INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounter value=9 type=hidden name=SEARCH_ROW_COUNT> <INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_openPDFAction value=/wps/myportal/OLB/!ut/p/c5/pdDBboJAEAbgZ-kTzMhS6B4XF7tYXQiwwHIhxFIjUSCNocLTF5sejIn00Jnjl3-SfyCHaZuyP-zL86FtyiNkkFuF771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uL2Vycm9yQWN0aW9u/ type=hidden name=errorAction> </FORM> <FORM id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_openDocForm1 method=post name=OpenDocForm1 action=/wps/myportal/OLB/!ut/p/c5/pdDBboJAEAbgZ-kTzMhS6B4XF7tYXQiwwHIhxFIjUSCNocLTF5sejIn00Jnjl3-SfyCHaZuyP-zL86FtyiNkkFuF771ZHjVR4Nrk6G1cIpi7WixXZHJ94_7i6lRQ4j_75BXJP9LoWH-kU8jQLKL6pdsO52wzLvu4HiOUnI3bcWfIzwqlDIL3JFQOc7TSxnHK5HNXbTLrpmff-V1jbsw7kln_6Xx1fDAMIaqaYslAivZUgYbcflgmsSD-fdFXN9BMXrhugx27DFSmARda7uP1KEKVMEV5Wqsn6E5K9Z0buh8MvwHnioy3/dl3/d3/L0lDU0lKSmdwcGlRb0tVUmcvb0tvZ0FFSVFoakVDVUlnQUVBSXlGQU1od1VoUzRKUkVBSUFBLzRDMWI5V19OcjBnQ1VneEVtUkNVd2chIS83X09JSzZJOTQwSDBKNEQwSUxFM0hBRUYxQ1Y2L0JuSld4OTQ2ODAwMzcvMTkwNjY3MzUwMTk0L2phdmF4LnBvcnRsZXQuYWN0aW9uL29wZW5QREZBY3Rpb24!/></FORM> <FORM id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_openConf method=post name=OpenConf action=/wps/myportal/OLB/!ut/p/c5/pdDRboIwGAXgZ_EBlr9aBuOyWlxxWBhQoNwYwjoGUSDOofL04rKLxUR2sf6XX85JTiGF4eqsK4vsUDZ1toUEUn3j2i-6bWqIoZVGke1YmBFrOV0s8eDyl7vTq5vMxO6ji58R_kcazfU_0jEkSNsE1VO7Ph8Sp190YdUHiFPSr_t8xvcKce55b5Ev5mQuhZxth0w61mrgUdds48ZvFtPZuCM86t-br47uPIIgUPVmQYCzZqdAQmrcHRPpEP580bE9mwk_Udl4OTmdTR57lElehKue-SIiwqRxJSZDnxzti_fqs_na5wr8plV1VKojvOZZ_qEc1amtlxUK2p0QXWv51juZPkgyuQCt4YTn/><INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounterConf type=hidden name=RowCounterConf> <INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_AddnDocTypeConf type=hidden name=AddnDocTypeConf> <INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_openPDFAction value=/wps/myportal/OLB/!ut/p/c5/pdDBboJAEAbgZ-kTzMhS6B4XF7tYXQiwwHIhxFIjUSCNocLTF5sejIn00Jnjl3-SfyCHaZuyP-zL86FtyiNkkFuF771ZHjVR4Nrk6G1cIpi7WixXZHJ94_7i6lRQ4j_75BXJP9LoWH-kU8jQLKL6pdsO52wzLvu4HiOUnI3bcWfIzwqlDIL3JFQOc7TSxnHK5HNXbTLrpmff-V1jbsw7kln_6Xx1fDAMIaqaYslAivZUgYbcflgmsSD-fdFXN9BMXrhugx27DFSmARda7uP1KEKVMEV5Wqsn6E5K9Z0buh8MvwHnioy3/dl3/d3/L0lDU0lKSmdwcGlRb0tVUmcvb0tvZ0FFSVFoakVDVUlnQUVBSXlGQU1od1VoUzRKUkVBSUFBLzRDMWI5V19OcjBnQ1VneEVtUkNVd2chIS83X09JSzZJOTQwSDBKNEQwSUxFM0hBRUYxQ1Y2L0JuSld4OTQ2ODAwMzcvMTkwNjY3MzUwMTk0L2phdmF4LnBvcnRsZXQuYWN0aW9uL29wZW5QREZBY3Rpb24!/ type=hidden name=openPDFAction> <INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_errorAction value=/wps/myportal/OLB/!ut/p/c5/pdDBboJAEAbgZ-kTzMhS6B4XF7tYXQiwwHIhxFIjUSCNocLTF5sejIn00Jnjl3-SfyCHaZuyP-zL86FtyiNkkFuF771ZHjVR4Nrk6G1cIpi7WixXZHJ94_7i6lRQ4j_75BXJP9LoWH-kU8jQLKL6pdsO52wzLvu4HiOUnI3bcWfIzwqlDIL3JFQOc7TSxnHK5HNXbTLrpmff-V1jbsw7kln_6Xx1fDAMIaqaYslAivZUgYbcflgmsSD-fdFXN9BMXrhugx27DFSmARda7uP1KEKVMEV5Wqsn6E5K9Z0buh8MvwHnioy3/dl3/d3/L0lDU0lKSmdwcGlRb0tVUmcvb0tvZ0FFSVFoakVDVUlnQUVBSXlGQU1od1VoUzRKUkVBSUFBLzRDMWI5V19OcjBnQ1VneEVtUkNVd2chIS83X09JSzZJOTQwSDBKNEQwSUxFM0hBRUYxQ1Y2L0duSld4OTQ2ODAwMzgvMTkwNjY3MzUwMTk1L2phdmF4LnBvcnRsZXQuYWN0aW9uL2Vycm9yQWN0aW9u/ type=hidden name=errorAction> </FORM> <FORM id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_openKioskProspAmd method=post name=OpenKioskProspAmd action=/wps/myportal/OLB/!ut/p/c5/pdDBboJAEAbgZ-kTzMhS6B4XF7tYXQiwwHIhxFIjUSCNocLTF5sejIn00Jnjl3-SfyCHaZuyP-zL86FtyiNkkFuF771ZHjVR4Nrk6G1cIpi7WixXZHJ94_7i6lRQ4j_75BXJP9LoWH-kU8jQLKL6pdsO52wzLvu4HiOUnI3bcWfIzwqlDIL3JFQOc7TSxnHK5HNXbTLrpmff-V1jbsw7kln_6Xx1fDAMIaqaYslAivZUgYbcflgmsSD-fdFXN9BMXrhugx27DFSmARda7uP1KEKVMEV5Wqsn6E5K9Z0buh8MvwHnioy3/dl3/d3/L2dJQSEvUUt3QS9ZQnZ3LzZfT0lLNkk5NDBIMEo0RDBJTEUzSEFFRjFDRjA!/ target=_blank><INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_RowCounterProspAmd type=hidden name=RowCounterProspAmd> <INPUT id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_AddnDocTypeProspAmd type=hidden name=AddnDocTypeProspAmd> </FORM> <DIV style="DISPLAY: none" id=ns_7_OIK6I940H0J4D0ILE3HAEF1CV6_attentionStmtTooLarge> ..... some style definitioan ...etc
-
Saturday, February 18, 2012 7:58 AM
there is a more complete html sample on sky drive
-
Tuesday, February 21, 2012 11:40 AMModeratorHi,
If I have not got it wrong, the html page you uploaded is the rendered result of your web form. But it won't do any good to our friends here on resolving your problem, you should provide us the web form files(.aspx, .aspx.cs, designer.cs, etc.)
Have a nice day,Leo Liu [MSFT]
MSDN Community Support | Feedback to us
-
Saturday, February 25, 2012 10:27 PM
thx for responding but l the web page is from a third party, and I can't get the designer, aspx stuff other just the html,
the complete orginal html had confidential info, so I had to edit to change the address, name,... etc
why it seem to respond to the last request from script invoke and ignore all prev? is there a way to program the script invoke so each appear to the last one in the series of execution?
or do Id to somehow bypass the script; post the required information like the javascipt does?
-
Monday, February 27, 2012 5:17 AMModeratorHi fs-ab,
So what is the C# app you are dealing with? A Winform one? Or a WPF one?
What is sReslt array and what is wbctl.getActiveBrowser()? Seems there isn't one member in .NET framework which provides the implementation of the getActiveBrowser method.
Thanks for your understanding and have a nice day,Leo Liu [MSFT]
MSDN Community Support | Feedback to us
-
Monday, February 27, 2012 7:58 AM
thx fot replying, my app is a winform
sReslt array is an array I parsed the required element ID and other paramters I found in the downlaod pdf input and javascript parameter associated.
wbctl.getActiveBrowser() is custom control member which returns the active Browser's DocumentText (html). sorry that I did not point that out
wbCtl derives from a custom class of tabcontrol with a minimum of one tabpage with a webbrowser and directs any new windows request to creating a new tabpage of another webbrowser on the tab control
the array sReslt was found to have the desired content albeit there was need for deduplication code for some pages. I think the 3 party webpage was designed for more than IE and repeat the table of available download somewhat different style for suit the browser
-
Wednesday, February 29, 2012 4:01 AMModeratorThen you should close this thread and post in the dedicated Windows
Forms General Forum for dedicated support.
Thanks for your understanding and have a nice day,Leo Liu [MSFT]
MSDN Community Support | Feedback to us

