Trying to click Javascript menu tree in IE (1 Viewer)

gypsyjoe11

Registered User.
Local time
Today, 04:23
Joined
Feb 19, 2010
Messages
46
When I take the url from the subframe and put it in the main browser I can view the source code and the text is there inside of a table.

But when I list all the dom elements and sub elements of those with my program there are no table tagnames?

Any ideas?
 

ajetrumpet

Banned
Local time
Today, 03:23
Joined
Jun 22, 2007
Messages
5,638
you having fun yet joe? :D hope you guys this one figured out. sure has a lot of effort put into it so far!
 

gypsyjoe11

Registered User.
Local time
Today, 04:23
Joined
Feb 19, 2010
Messages
46
from view source in browser

Code:
<TD>
<LABEL FOR='ALL_CRS_SRCH_VW_COURSE' CLASS='PSSRCHEDITBOXLABEL' >Course Code:</LABEL>
</TD>

A printout of all the tagnames in the url is:

Code:
--> HTML
    --> HEAD
        --> TITLE
    --> TITLE
    --> BODY
        --> MAP
            --> AREA
        --> AREA
        --> IMG
    --> MAP
        --> AREA
    --> AREA
    --> IMG
--> HEAD
    --> TITLE
--> TITLE
--> BODY
    --> MAP
        --> AREA
    --> AREA
    --> IMG
--> MAP
    --> AREA
--> AREA
--> IMG

Notice that there is no table shown above.
 
Last edited:

darbid

Registered User.
Local time
Today, 10:23
Joined
Jun 26, 2008
Messages
1,428
I dont understand what you are posting.

Can you post the full table outerhtml code.

If you cannot post it. I will try and guess for you.

First get the table element.

Then see if it has TR or TD's in it. You text is going to be in one of them.

Once you get the table as an object then loop through it with a

For each object in tableelement

if instr(object.innerhtml, "tree choice text")
object.click
end if

next
 

gypsyjoe11

Registered User.
Local time
Today, 04:23
Joined
Feb 19, 2010
Messages
46
That's the problem, there is no table. I can see it when I view the source code in the browser. However I can't see a table element inside of VBA.
 

gypsyjoe11

Registered User.
Local time
Today, 04:23
Joined
Feb 19, 2010
Messages
46
Here is the VBA code that is run on the URL.

Code:
Public Function PrintDom(mainFrame As HTMLDocument)
    Dim domElement1 As HTMLGenericElement
    Dim domElement2 As HTMLGenericElement
    Dim domElement3 As HTMLGenericElement
    Dim domElement4 As HTMLGenericElement
    Dim domElement5 As HTMLGenericElement
    Dim domElement6 As HTMLGenericElement
    Dim domElement7 As HTMLGenericElement
    Dim domElement8 As HTMLGenericElement
 
    Dim findText As String
    findText = "Course"
 
    For Each domElement1 In mainFrame.all
        Debug.Print "--> " & domElement1.tagName
        For Each domElement2 In domElement1.all
            Debug.Print "    --> " & domElement2.tagName
            For Each domElement3 In domElement2.all
                Debug.Print "        --> " & domElement3.tagName
                For Each domElement4 In domElement3.all
                    Debug.Print "            --> " & domElement4.tagName
                    For Each domElement5 In domElement4.all
                        Debug.Print "                --> " & domElement5.tagName
                        For Each domElement6 In domElement5.all
                            Debug.Print "                     --> " & domElement6.tagName
                            For Each domElement7 In domElement6.all
                                Debug.Print "                          --> " & domElement7.tagName
                                For Each domElement8 In domElement7.all
                                    Debug.Print "                               --> " & domElement8.tagName
                                Next
                            Next
                        Next
                    Next
                Next
            Next
        Next
 
    Next
 
 
End Function

When run it doesn't show any elements with a TD or TR tag.

But when I view the source through the IE menu bar it clearly shows up.
 

darbid

Registered User.
Local time
Today, 10:23
Joined
Jun 26, 2008
Messages
1,428
Without getting the site some way as I have suggested you are going to have to explore yourself.

My thoughts are 1. It is in a frame that you have not found yet. 2. The frames or main doc changes with certain interaction Including for example mousehover. In fact moushover might be it.

I would suggest you work on my code above to print the outerHTML of all frames and subframes. I would be surprised if my code works without a little bit of tweaking. Then do a text search of the resulting txt file.
 

gypsyjoe11

Registered User.
Local time
Today, 04:23
Joined
Feb 19, 2010
Messages
46
Thanks Darbid and everyone else for your input.

I've got to finish a big report that my boss has been waiting for. I'm hoping to have it done and back to my investigation by the middle of next week.

I'll be posting more then on my progress.

My final thoughts for now are that maybe it is php or something else on the server that is making the table menus. Maybe I won't be able to see a table until I call the appropriate javascript(or something else) that gets it from the server? I'm still learning about web programming. :D

Joe
 

darbid

Registered User.
Local time
Today, 10:23
Joined
Jun 26, 2008
Messages
1,428
My final thoughts for now are that maybe it is php or something else on the server that is making the table menus. Maybe I won't be able to see a table until I call the appropriate javascript(or something else) that gets it from the server? I'm still learning about web programming. :D
Joe
Thats correct. But as IE is not magic it must have it in its source otherwise it cannot display it and it must be in a DOM (Document Object Model format). Thus you just have to take it step for step. Following the exact same method that you would use with your keyboard or mouse.

I am still of the the opinion that as long as it is not a java applet you can do it with VBA.

There is also little more I might be able to help you with as I am already just guessing.
 

gypsyjoe11

Registered User.
Local time
Today, 04:23
Joined
Feb 19, 2010
Messages
46
Well I feel stupid. It turns out I wasn't able to see the information I wanted because I wasn't waiting until the page was done loading.

As soon as I added:

Code:
Do: Loop Until Not IEwindow.Busy

I was able to see all the information on the page and find out the name of the items I wanted.

I then successfully entered the course code into the input box with

Code:
SubSubFrame.getElementById("ALL_CRS_SRCH_VW_COURSE").Value = "340720"

and clicked the search button with

Code:
SubSubFrame.getElementById("#ICSearch").Click

Anyway, thanks for the help everyone.

I think I'm going to add the wait loop after every line of code just to be safe :)

Joe
 

darbid

Registered User.
Local time
Today, 10:23
Joined
Jun 26, 2008
Messages
1,428
Code:
Do: Loop Until Not IEwindow.Busy
Just a word of advice. You not only have to deal with IE being busy but also the page and each frame on the page. Each one can be busy.

You might also need some "DoEvents" in your loop in case IE takes a long time.

Also in my experience some IE's, webpages and subforms might stay busy even though they are not, thus you need to build in some exits. You DO will continue to loop for example if this intranet site is not available.
 

gypsyjoe11

Registered User.
Local time
Today, 04:23
Joined
Feb 19, 2010
Messages
46
Thanks Darbid,

The modified version of your program to make the text file out of the outerHTML at first didn't have any tables in it. After waiting for IE to be done the text file was 2mb!

I found a way that seems to only print out what I want using:

Code:
debug.Print SubSubFrame.documentElement.innerText

and

Code:
debug.Print SubSubFrame.documentElement.innerHTML

I put a break in the program and then used the above in the intermediate window.

Below is the working code in case it can help someone else who has frame problems.

Code:
Dim DisplayBox As VbMsgBoxResult
  'find the right internet explorer webpage
    Dim allExplorerWindows As New SHDocVw.ShellWindows
    Set allExplorerWindows = New SHDocVw.ShellWindows
 
    Dim IEwindow As SHDocVw.InternetExplorer
    Dim foundFlag As Boolean
    foundFlag = False
 
    For Each IEwindow In allExplorerWindows
        If InStr(IEwindow.LocationURL, ".xxxxxx.us") <> 0 Then
            foundFlag = True
            Exit For    'found the right IE window URL
        End If
    Next
 
    If Not foundFlag Then
        DisplayBox = MsgBox("Could not find an open instance of xxxx xxxx running." _
            & vbNewLine & vbNewLine & " " & _
            "You can contact the program author if assistance is needed." & _
            vbNewLine & "xxxxxxxx" & _
            vbNewLine & "email at xxxxxxx", _
            vbOKOnly + vbMsgBoxSetForeground, "Please try again.")
        GoTo Exit_Get_DA
    End If
    IEwindow.Visible = True      'set IE window to active
  'end find
    'set myHTMLDoc to the main pages IE document
    Dim myHTMLDoc As HTMLDocument
    Set myHTMLDoc = IEwindow.document
 
    'get sub frame0 from myHTMLDoc
    Dim SubFrame0 As HTMLDocument
    Set SubFrame0 = myHTMLDoc.frames(0).document
 
    'get sub frame1 from myHTMLDoc
    Dim SubFrame1 As HTMLDocument
    Set SubFrame1 = myHTMLDoc.frames(1).document
 
    'Navigate frame1 to the TAS module
    Do: Loop Until Not IEwindow.Busy    'wait until IE is finished loading
    SubFrame1.URL = "[URL]https://xx.xxxxx.xx/servlets/iclientservlet/xxxxx/?ICType=Nav[/URL]"
 
    'Navigate to the Course Profile area
    Do: Loop Until Not IEwindow.Busy    'wait until IE is finished loading
    Dim SubSubFrame As HTMLDocument
    Set SubSubFrame = SubFrame1.frames(2).document
    SubSubFrame.URL = "[URL]https://xx.xxxxx.xx/servlets/iclientservlet/xxxxx/?ICType=Panel&Menu=ADMINISTER_TRAINING_(GBL)&Market=GBL&PanelGroupName=COURSE_TABLE2[/URL]"
 
    'enter the course # and then press the "search" button
    Do: Loop Until Not IEwindow.Busy    'wait until IE is finished loading
    SubSubFrame.getElementById("ALL_CRS_SRCH_VW_COURSE").Value = "340720"
    SubSubFrame.getElementById("#ICSearch").Click

Hope this helps someone else,

Joe
 

gypsyjoe11

Registered User.
Local time
Today, 04:23
Joined
Feb 19, 2010
Messages
46
I got it all working. I made my program in Excel. I found out that I had to wait for excel to be ready before reading values from it.

Code:
Do: Loop Until xlObj.Ready

The program was working fine as long as you didn't try and do anything else while it was running. If you did it would repeat old values and have lots of duplicates. Now you can work on other stuff and come back when it's done.

If anyone wants help activating Javascript buried within frames within table cells, let me know.

Joe
 

neveu

New member
Local time
Today, 11:23
Joined
Feb 3, 2013
Messages
1
Hello forum,
I have a similar situation for which I would appreciate your help:

there is a web page having 2 frames :
in the left frame there is a treelist menu ; from here I need to go thtough the specific line and then in the right part it will display a table containing the list of files that I would need to download .

I would like to request for your help to be able to drill down to the specific tree list menu and then download the files from the right menu.

looking forward for your help
 

darbid

Registered User.
Local time
Today, 10:23
Joined
Jun 26, 2008
Messages
1,428
Hi neveu,

Please post the code you have so far that opens IE and at least goes to the page you want.

Please supply a link to the web page.

Please identify each element you have explained in words in your text with the elements in the HTML, this means going to the HTML for the page / frame and then finding the line of HTML which creates the elements you want to control.

Then lets see what we can do.
 

Users who are viewing this thread

Top Bottom