Jump to content
Sign in to follow this  
Prime03

(_IE) Unable to get TextArea Innertext or Value

Recommended Posts

Prime03

Hey guys I'm scraping a webpage and seem to be unable to get the .innertext or .value properties of a Textarea element to return the actual displayed text.

Here is the tag,

<textarea tabIndex="-1" class="disinput" id="problem_desc" style="width: 450px; overflow: auto;" onclick="" onchange="return(ItemChange(this,1-1))" onbeforedeactivate="return(AO_ItemBeforedeactivate(this,1-1))" rows="3" readOnly="">
    Text - ;The displayed text is here
  Text - Empty Text Node

Here is my capture

Local $mainProblemDescription = _IEGetObjbyID ($oFrame, "problem_desc")

MsgBox(0, "test", $mainProblemDescription.value)
MsgBox(0, "test", $mainProblemDescription.innerText)
MsgBox(0, "test", $mainProblemDescription.innerHTML)

All of these attempts return 0

Any suggestions?
Thanks

Share this post


Link to post
Share on other sites
DaleHohm

Do some things programmatically to insure you are talking to the right element... set it's value, change it's style, etc.  Note that the attached onchange event may be messing with you.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites
Prime03

Dale!

Well I went to try your suggestion this morning and confirm I was linked to the right element, confirmed with a  simple

$mainProblemDescription.innertext = "test"

and yes I was able to successfully change the field. And then I went and tried to pull the text again using the same code as yesterday and it freaking worked! The only thing that changed between yesterday and today is the length of the text in the field, but I'm SURE that must be irrelevant to calling a property.

If you have the time I was really hoping I could get your opinion on another problem I've had for quite some time in regards to script tags and calling buttons that are contained within them. What I'm working with is a report window that is generated that looks like this,

2eob05t.png

 

I'm trying to call the Export or Print buttons that are on the report, which appear to be contained in some javascript. I've isolated that tag to be this one,

<SCRIPT id=arvToolbarClick language=javascript for=arv defer event=ToolbarClick(Tool)>      
        if (Tool.ID == 1)
        {
            Export();
        }                   
        else if (Tool.ID == 2)
        {           
            arv.UseSourcePrinter = true;
            Tool.Enabled = false;
            arv.Printer.MaxPage = arv.Pages.Count();
            bReturn = arv.Printer.PrintDialog();
            
            if (bReturn)
            {                   
                arv.PrintReport(false);                             
                DoOperationsFromClient("print finished");
            }
            Tool.Enabled = true;
        }

        //New Function to download Export File from the Server (comes from standard AO_DownLoadFile function)
        function DownloadFile( relativePath, filename, toBeDeleted, SessionID )
        {
            //debugger;
            if ( relativePath == null || relativePath == "" ) return;
            if ( filename == null ) filename = relativePath.substr( relativePath.lastIndexOf('\\') + 1 );

            if ( toBeDeleted == null ) toBeDeleted = "no";
            //window.open("../Web_Framework/Download.aspx?SessionID=" + SessionID + "&id=" + relativePath + "&name=" + filename + "&delete=" + toBeDeleted, "_blank" );
            
            
            var linkObj = opener.top.uploadFrame.document.getElementById("attachment_link");
            linkObj.href = "../Web_Framework/Download.aspx?SessionID=" + _GetGlobalVar("SessionID") + "&id=" + relativePath + "&name=" + filename + "&delete=" + toBeDeleted;
            linkObj.focus();
            linkObj.click();

        }

        //NAT New function to perform Report Export process
        function Export()
        {
            //debugger;
            var obj = document.getElementById("sessionIDParameter");
            var Session = obj.value;

            obj = document.getElementById("findXMLParameter");
            var FindXML = obj.value;

            obj = document.getElementById("reportNameParameter");
            var ReportName = obj.value;
        
            var params = new Array( Session, FindXML, ReportName, window );

            var res = window.showModalDialog('../form_asp/activereportexport.htm',params,'dialogWidth:300px;dialogHeight:320px;status:no;toolbar:no;scroll:no;center:yes;help:no');
            
            if ( res == null ) return;
            var FileName = res[0];
            //debugger;
            DownloadFile( FileName, null, "yes" , Session );
        }           
        </SCRIPT>

I notice right away the Export(); function and the code relating to using the local printer, I'm sure I'm interested in this tag.

A few things I've tried are

$oReportWindow.document.parentwindow.execscript("Export()")

or
$oReportWindow.document.parentwindow.execscript("ToolbarClick()", "1")

or
$oReportWindow.document.parentwindow.execscript("ToolbarClick()")

or
$oReportWindow.document.parentwindow.execscript("ToolbarClick(1)")

Now I get a result from calling Export(), but crazy enough is that it's not actually the window that comes up when you click on the Export button on the report page! Regardless, the first line gives me a confirmation I'm calling...something...correctly. Now I've been trying to find the correct syntax for calling what I believe are the 'Toolbar' IDs to get the right window to show up.

Having this work is not required for me to complete any projects I'm working on, but it's something I'd like to have the option to do if needed. I'm not expecting any answers or solutions, but any thoughts on this would be greatly appreciated!

As I'm reviewing this post I noticed another method I will try when I get the chance today, I'm not sure what the arv. infront of it means right now but this seems like it's worth a shot. I'll update later today after fiddling with it some more.

$oReportWindow.document.parentwindow.execscript("PrintReport()");

 

Thanks for your time!
 

Share this post


Link to post
Share on other sites
DaleHohm

The arv is the element that the script is bound to (for=arv).  The script is called with an appropriate event on that element triggers it.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×