473,465 Members | 1,444 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

C#(VS 2003) - HTMLAnchorElementClass .click method

1 New Member
Good morning,

A little background - I'm a QA automation engineering(working with Mercury/HP's Quick Test Professional) who is just delving into some C# programming to solve some of our issues. I would consider my skillset at the level: "Trained monkey, without the training".

We have a .Net application that has some browser controls somehow imbedded such that our automation tool can only access it in a very limited fashion. Through a lot of Googling, I have discovered if I create a IHTMLDocument2 interface to the object I can access virtually everything. I've verified that I can create a C# .DLL and call that with our testing tool.

The C# programm I have created, I'm able to return the object "htmlDocument", write out various properties like innerText.

I am having trouble with the .click method. It partally works in such a way that the link is clicked and the required window is opened. However, the following two things happen:

1 - The code appears to "hang" in the .click method until I close the window that the .click method opened up.

2 - If I take out the Try/Catch block, an exception is thrown when I close the window. The exception is:
Unhandled Exception: System.Runtime.InteropServices.COMException (0x80004004): Operation aborted

My guess is that the .click method is somehow simulating some type of mousedown and mouseup combination, but for whatever reason, it is not completing it.

Any suggestions how to work around this?

Thanks in advance for any help.

-Ed







Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using McK.Automation.Text;
  3. using System.Runtime.InteropServices;
  4. using mshtml;
  5. using System.Collections;
  6. using System.Text.RegularExpressions;
  7.  
  8. namespace testApplication
  9. {
  10.     /// <summary>
  11.     /// Summary description for Class1.
  12.     /// </summary>
  13.     class testApplication
  14.     {
  15.         /// <summary>
  16.         /// The main entry point for the application.
  17.         /// </summary>
  18.         [STAThread]
  19.         static void Main(string [] args)
  20.         {
  21.             ObjectText Text = new ObjectText();
  22.             IHTMLDocument2 htmlDocument = Text.ReturnIEDocumentObject(656656);
  23.             //
  24.             //Capture the innerText property of the object
  25.             //
  26.             string innerText = htmlDocument.body.innerText;            
  27.             Console.WriteLine("Value:  {0}", innerText.ToString());
  28.  
  29.             IHTMLElementCollection links = htmlDocument.links;
  30.             foreach (HTMLAnchorElementClass el in links)
  31.             {
  32.                 Console.WriteLine("Value:  {0}", el.innerText);
  33.                 Match m = Regex.Match(el.outerHTML, ".*aspirin.*");
  34.                 if (m.Success)
  35.                 {
  36.                     Console.WriteLine("Value:  {0}", el.innerText);
  37.                     try
  38.                     {
  39.                         el.
  40.                         el.click();
  41.                         break;
  42.                     }
  43.                     catch
  44.                     {
  45.  
  46.                     }
  47.                 }
  48.             }
  49.         }
  50.     }
  51. }
Mar 25 '08 #1
0 1776

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

Similar topics

2
by: Rick Austin | last post by:
I recently had to perform a reinstalltion of Windows XP (my registry seems to have become corrupt). After this completed I had to reinstall all applications since most use the registry for settings,...
3
by: Chris Kilmer | last post by:
I would like to be able to customize the path structure that VS.NET 2003 creates for projects. 1. I'd like to be able to create a project without VS.NET creating a folder for that project. ...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
3
by: Arun Kumar | last post by:
Hi I am new to .NET. I have VS.NET 2003 and VS.NET 2005 Beta 2 Installed on my PC. I created a Windows Application which uses COM object. Its a simple test. When I Build the application on VS...
5
by: Woody Splawn | last post by:
Forgive my ignorance but how do you get your applicaiton written in VS from your localhost to your actual web site? Is there a way of doing this from within VS or do you have to use some sort of...
2
by: harry | last post by:
Hi, After installing VS.2003, I just upgraded a VS.NET 2002 project to VS.NET 2003. I upgraded because VS.NET 2003 is slow and buggy. However, I find VS.NET 2003 is worse in terms of bugs....
5
by: Ken Varn | last post by:
I have just started using VS.NET 2005 after using VS.NET 2003. One of the things that I noticed is that in ASP.NET, the DataSource property for TextBoxes and other web controls is no longer...
8
by: Learner | last post by:
Hello, I converted a VS 2003 project to VS 2005. It works perfectly alright in VS 2003 but when I try running in VS 2005 I got strange thing going on. The code (my button click event ) runs...
3
by: moondaddy | last post by:
What's the preferred (best) way to start a website project in VS 2005? I know of 2 ways and each creates a site differently and has different behavior. Open VS 2005 1) from the start page...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.