6 Replies - 1258 Views - Last Post: 17 February 2013 - 01:30 PM Rate Topic: -----

#1 lacrue79  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 43
  • Joined: 12-August 09

Help using MSHTML in VB.net to auto select Web Page Tabs

Posted 17 February 2013 - 09:17 AM

I am creating a windows based application that will call a webpage and input information into the web page. I need to be able to clickon the tabs within the web page but I can't seem to get that to work. I'm new to using MSHTML so I don't quite understand it all. Any guidance is much appreciated.

Here is the source code from the web page that I'm trying to access a tab titled "Informational Only". By the way there are over 10 tabs available to select this is just a snap shot of one. I'd need to be able to click on any of the tabs.
<DIV lang="" class=dijitTab role=presentation dojoAttachPoint="titleNode" dojoAttachEvent="onclick:onclick" widgetId="dijit_layout_TabContainer_1_tablist_dijit_layout_ContentPane_6" waiRole="presentation">
<DIV class=dijitTabInnerDiv role=presentation dojoAttachPoint="innerDiv" waiRole="presentation">
<DIV class=dijitTabContent role=presentation dojoAttachPoint="tabContent" waiRole="presentation">
<DIV id=dijit_layout_TabContainer_1_tablist_dijit_layout_ContentPane_6 title="" role=tab tabIndex=-1 aria-pressed=false aria-selected=false unselectable="on" dojoAttachPoint="focusNode" waiRole="presentation" checked="false"><IMG class="dijitIcon dijitTabButtonIcon" alt="" src="http://bnlpcq.testing.com:12080/cqweb/scriptsx/dojox-1.5/dojo/resourcesx/blank.gif" unselectable="on" dojoAttachPoint="iconNode"> <SPAN class=tabLabel unselectable="on" dojoAttachPoint="containerNode">[b]Informational Only[/b]</SPAN><SPAN style="DISPLAY: none" class="dijitInline dijitTabCloseButton dijitTabCloseIcon" role=presentation unselectable="on" dojoAttachPoint="closeNode" dojoAttachEvent="onclick: onclickCloseButton" waiRole="presentation"><SPAN class=dijitTabCloseText unselectable="on" dojoAttachPoint="closeText">x</SPAN></SPAN> </DIV></DIV></DIV></DIV>




I've tried using the following line of code but I get the error: Object reference not set to an instance of an object.

InputElem("Informational Only").click()



and here is the InputElem code. This works for adding data to text boxes and such I just can't seem to figure out how to click on the multiple tabs that are available in the web page. Thanks in advance for your help.
    Property InputElem(ByVal sName As String) As mshtml.HTMLInputElement
        Get
            If Doc Is Nothing Then Exit Property
            InputElem = Doc.getElementById(sName)

        End Get
        Set(ByVal value As mshtml.HTMLInputElement)

        End Set
    End Property



Is This A Good Question/Topic? 0
  • +

Replies To: Help using MSHTML in VB.net to auto select Web Page Tabs

#2 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3360
  • View blog
  • Posts: 11,397
  • Joined: 12-December 12

Re: Help using MSHTML in VB.net to auto select Web Page Tabs

Posted 17 February 2013 - 10:45 AM

You can delete the Set..End Set, it is not appropriate.

There is no element with the ID "Informational Only"; besides, IDs cannot contain spaces.

You need to examine the page separately, using the Google Chrome Console or FireBug, to work out which element has the click-event that activates the tab. If this element has an ID then you can use that, otherwise you'll need to loop through a collection of elements until you find the right one, then call .click() on the element.

The page uses the dojo toolkit which makes your task a little more complicated.
Was This Post Helpful? 0
  • +
  • -

#3 lacrue79  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 43
  • Joined: 12-August 09

Re: Help using MSHTML in VB.net to auto select Web Page Tabs

Posted 17 February 2013 - 12:39 PM

Hello, thanks for the response. I don't have either of those programs. I believe that the element ID I need to use is

dijit_layout_TabContainer_1_tablist_dijit_layout_ContentPane_6



This is the only element that is unique between all the tabs other than the lable names such as "Informational Only"; however, when I use that the click event with that element ID I get the error message:
Unable to cast object of type 'mshtml.HTMLDivElementClass' to type 'mshtml.HTMLInputElement'.

InputElem("dijit_layout_TabContainer_1_tablist_dijit_layout_ContentPane_6").click()



Does anyone have any ideas how I can get this to work? I need to activate the tabs to get to the source code because I can't seem to get to the source code to call the elements within each tab until the tab has been activated at least once. Thanks everyone.
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3360
  • View blog
  • Posts: 11,397
  • Joined: 12-December 12

Re: Help using MSHTML in VB.net to auto select Web Page Tabs

Posted 17 February 2013 - 01:19 PM

That error message is quite clear: the element is a DIV, not an INPUT element.

You don't need to use your function InputElem:

Doc.getElementById("dijit_layout_TabContainer_1_tablist_dijit_layout_ContentPane_6").click()

but, of course, this assumes that the DIV has a click-event assigned to it.
Was This Post Helpful? 1
  • +
  • -

#5 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3360
  • View blog
  • Posts: 11,397
  • Joined: 12-December 12

Re: Help using MSHTML in VB.net to auto select Web Page Tabs

Posted 17 February 2013 - 01:24 PM

Quote

I don't have either of those programs.

If you use Google Chrome then you already have its Developer Tools installed. Internet Explorer, and Opera (Dragonfly), have similar tools.
Was This Post Helpful? 0
  • +
  • -

#6 lacrue79  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 43
  • Joined: 12-August 09

Re: Help using MSHTML in VB.net to auto select Web Page Tabs

Posted 17 February 2013 - 01:28 PM

Thank you Andrew. that worked!! I admit I need to understand this stuff better. I greatly appreciate you and your time.
Was This Post Helpful? 0
  • +
  • -

#7 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3360
  • View blog
  • Posts: 11,397
  • Joined: 12-December 12

Re: Help using MSHTML in VB.net to auto select Web Page Tabs

Posted 17 February 2013 - 01:30 PM

View Postlacrue79, on 17 February 2013 - 01:28 PM, said:

Thank you Andrew. that worked!! I admit I need to understand this stuff better. I greatly appreciate you and your time.


No worries! Andy
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1