Click the Gmail Refresh Button

I am writing a simple personal application that has a browser control and I want it to automatically update gmail to check it more often than by default. There are monkey scenarios that do this, but I'm trying to add my personal style to it.

Anyway, I looked around and found everything, but what can I do in csharp using a browser control.

I found this:

// Link the ID from the web form to the Button var theButton = webBrowser_Gmail.Document.GetElementById("Refresh"); // Now do the actual click. theButton.InvokeMember("click"); 

But it returns with a null value in 'theButton', so it does not call anything.

Anyone have any suggestions?

+4
source share
2 answers

It has been a while since I used JavaScript, but given other answers and comments that there is no real identifier associated with the element, you could do something like the following:

  • Search all Divs with Role == 'Button' and InnerHtml == 'Refresh' attributes.
  • Once the correct InnerHtml is found, get the element.
  • Click on the found item.

Again, it could be smoke, but I thought I would throw it away.

edit : just realized that you are doing this using C # and a browser; however, the concept will still be the same.

+2
source

The best offer I could give you at this point includes the existing API, which is used for automation based on the .NET web browser:

http://watin.org/

Since the div tag with the right button really only identifies itself with the class name, you can use the code Find.BySelector ("") included in the latest version of watin.

+1
source

Source: https://habr.com/ru/post/1345574/


All Articles