Click here to Skip to main content
15,896,606 members

Gmail - DIV vs BUTTONS - How to invoke CLICK?

South 305 asked:

Open original thread
I'm trying to FORWARD and email from GMAIL using the WebBrowserControl (C#).

-I am able to open the Gmail INBOX page on the WebBrowserControl...
-I am able to OPEN the specific email (among the others on the inbox) that I need to forward...
-I am able to find and click the FORWARD link to start working with the email fields (TEXTS)...
-I am able to add/insert the email that I would like to send TO...
-I am able to add/edit the content of the email body...

However, now that I am done with the email I CAN'T SEND IT. I need to invoke/click the SEND button but Gmail uses DIV instead of BUTTONS and the regular CLICK does not work.

This is what I did so far. Since most of the DIVs do not have ID, I iterate through all the DIVs inside the Gmail MAIN FRAME (canvas_frame)....

HTML
webIE.Document.Window.Frames["canvas_frame"].Document.Body.GetElementsByTagName( "div" );

...and with a regular expression I was able to find the right DIV that contains the text(SEND) that I need to click. Here is the sample on how GMAIL encapsulates the HTML 'SEND' BUTTON = DIV (the same apply to most of the buttons like SAVE NOW, DISCARD, etc).
HTML
<div id=":j5" class="J-K-I J-J5-Ji Bq L3" role="button" tabIndex="1" unselectable="on">
    <div class="J-J5-Ji J-K-I-Kv-H" unselectable="on">
        <div class="J-J5-Ji J-K-I-J6-H" unselectable="on">
            <div class="J-K-I-KC" unselectable="on">
                <div class="J-K-I-K9-KP" unselectable="on"> </div>
                <div class="J-K-I-Jz" unselectable="on">Send</div>
            </div>
        </div>
    </div>
</div>

I first tried invoking click ( InvokeMember("click") ) on the inner DIV containing the SEND text:
HTML
<div class="J-K-I-Jz" unselectable="on">Send</div>

...but unfortunately did not work, then I tried invoking click on all and any of the DIVs (Parent/Children) of the above HTML code with no luck at all.

Any IDEA/ADVICE on how can I get to SEND the email?

++Thanks
Tags: C#, HTML, Visual Studio, DOM, WebBrowserControl

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900