开发者

Click Gmail Refresh button

开发者 https://www.devze.com 2023-02-20 02:57 出处:网络
I am writing a simple personal app that has a browser control and I want it to automatically \"Refresh\" gmail to check it more often than it does by default. There are monkey scripts that do this but

I am writing a simple personal app that has a browser control and I want it to automatically "Refresh" gmail to check it more often than it does by default. There are monkey scripts that do this but I'm trying to add my personal style to it.

Anyhow, I've looked around and found everything but what I can do in csharp using the browser control.

I found this:

// Link the ID from the w开发者_如何学Pythoneb form to the Button var
theButton = webBrowser_Gmail.Document.GetElementById("Refresh");

// Now do the actual click.
theButton.InvokeMember("click");

But it comes back with null in 'theButton' so it doesn't invoke anything.

Anyone have any suggestions?


It's been awhile since I've used JavaScript, but given the other answers and comments that there is no real ID associated with the element, could you do something like the following:

  1. Search all Div's with an attribute of Role == 'Button' and an InnerHtml == 'Refresh'.
  2. Once the correct InnerHtml is found, get the Element.
  3. Invoke the click on the found Element.

Again, this may be blowing smoke, but thought I'd throw it out there.

edit: Just realized you are doing this with C# and a browser control; however, the concept would still be the same.


The best suggestion I could give you at this point involves an existing API that is used for .NET web browser based automation:

http://watin.org/

Since the div tag with the desired button really only seems to identify itself with the class name, you could use the Find.BySelector(“”) code included with the most recent version of watin.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号