473,378 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

VB.net htmlDocument automate element within a FRAME

I'm having problems with a VB.NET application.

We have multiple web applications and we are using a VB.NET program to do a sort of Single Sign On. So this works great, the system automatically finds the element <input name = "user" etc..> and <input name = "password" etc.> and we use the click() command on an image to login.

One of the web applications uses complex javascript / ajax - and loads tables into frames.

So I can see the frames:

<frame name = "main" etc.> and <frame name ="info" etc.>

The element we are trying to access is in a table within frame MAIN. So I'm trying to figure out a way to cascade my way into FRAME Main and then be able to send information to an "input" element within that table of the frame.

I know this can be done but I'm having problems getting it to work.

Any help would be appreciated.

Lee
Jan 5 '08 #1
1 6466
Here is just a sample code:

So if you go to a site like www.ogame.org (just an example that someone else posted), you have the username / password input elements encapsulated within frame(0).

Expand|Select|Wrap|Line Numbers
  1. Dim HTMLDoc As mshtml.HTMLDocument
  2.  
  3.  
  4.  
  5.         HTMLDoc = WebBrowser1.Document
  6.  
  7.         'select the inner frame
  8.  
  9.         Dim f1 As mshtml.IHTMLWindow2 = CType(HTMLDoc.frames.item(0), mshtml.IHTMLWindow2)
  10.  
  11.         'verify with msgbox display inner frame only
  12.  
  13.         MessageBox.Show(f1.document.body.innerHTML)
  14.  
  15.         'convert inner frame HTML to HTMLdocument (error here)
  16.  
  17.         Dim obj2 As mshtml.HTMLDocument = CType(f1.document.body.innerHTML, mshtml.HTMLDocument)
  18.  
  19.         'scan through inner frame elements search for input elements
  20.  
  21.         Dim wbrAll As mshtml.IHTMLElementCollection = obj2.getElementsByTagName("input")
  22.  
  23.         ' Create an object that will be a single instance of an input element
  24.  
  25.         Dim wbrElm As mshtml.IHTMLElement
  26.  
  27.  
  28.  
  29.         ' Create a few variable to hold values from the input element
  30.  
  31.         Dim strName As String
  32.  
  33.         Dim strId As String
  34.  
  35.         Dim strvalue As String
  36.  
  37.         Dim strType As String
  38.  
  39.  
  40.  
  41.         For Each wbrElm In wbrAll
  42.  
  43.  
  44.  
  45.             ' Assign the inner html values of the input to our variables
  46.  
  47.             strName = wbrElm.getAttribute("name")
  48.  
  49.             strId = wbrElm.id
  50.  
  51.             strvalue = wbrElm.innerText
  52.  
  53.             strType = wbrElm.getAttribute("type")
  54.  
  55.  
  56.  
  57.             MsgBox("name: " & strName & " Id: " & strId & " Value: " & strvalue & " Type: " & strType)
  58.  
  59.         Next
  60.  
  61.  





I'm having problems with a VB.NET application.

We have multiple web applications and we are using a VB.NET program to do a sort of Single Sign On. So this works great, the system automatically finds the element <input name = "user" etc..> and <input name = "password" etc.> and we use the click() command on an image to login.

One of the web applications uses complex javascript / ajax - and loads tables into frames.

So I can see the frames:

<frame name = "main" etc.> and <frame name ="info" etc.>

The element we are trying to access is in a table within frame MAIN. So I'm trying to figure out a way to cascade my way into FRAME Main and then be able to send information to an "input" element within that table of the frame.

I know this can be done but I'm having problems getting it to work.

Any help would be appreciated.

Lee
Jan 6 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mark | last post by:
Hello I have a page with an inline frame "frameA" on it. Within the frame is a table and within that is a cell with the id "morebit" Previously I would set the innerHTML for this cell from the...
1
by: Tristan Miller | last post by:
Greetings. Here is the scenario: I have an element div.aside which is absolutely positioned in the bottom right corner of its containing box, div.frame. Said containing box is then resized...
7
by: David Hayes | last post by:
I tried finding an answer on http://www.quirksmode.org/ without success. I am attempting a complicated Frames structure. I have made it work in IE, but not Netscape. I begin with three...
0
by: Filippo Bettinaglio | last post by:
VS2005, C# I have developed a UserControl embedded in a HTML web page. And I can access to the DOM with the following code: HTML page: …….. <BODY onload=loadDoc()> …….
2
by: Paul Hemans | last post by:
I am very new at .Net. I have a small project where I need to manipulate the contents of a web page. I have a form with a web browser control (webBrowser1) on it. Within the...
14
by: kelvin.jones | last post by:
Hi, if I had the ID of an input element, how can I find the input's FORM in javascript? Basically, given a input's dom id, I want to insert something in the onSubmit of the Form that that input...
0
by: forcedfx | last post by:
I'm faced with a bit of a conundrum. I'm trying to post a form using the HTMLDocument object. I've got the form posting working prefectly, however, in order to retrieve the HTML page that contains...
5
by: Jeff | last post by:
Is there a standard way of getting the HTMLDocument object representation of a remote page using Javascript? If I request an HTML page, the xmlHttpRequest returns either text or an XMLDocument. I...
0
by: nickin4u | last post by:
I have a application that is used to automate certain task, I have been using mshtml.HTMLDocument class but certain events like click a button do not fire. I have tried a number of combinations but...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.