user671805
user671805

Reputation: 602

Emulating click based event on a web page

This link goes to an implementation of the imagination captcha imagination

The authors have themselves requested for people to make algorithms to try its efficiency against AI attacks.

Essentially the first page is asking for a mouse click anywhere on the image... My problem is that my algorithm comes up with the point (x,y) on the image but I want to emulate it real time on this link...

Can some one tell me how can i send the point values on this link and get back the message whether i was successful or not....

Essentially I am asking how can i emulate a mouse click on this link at the points that my algorithm gives using C#...

I am asking this only for studying the features of this captcha and its accuracy.

Thanks a lot

Upvotes: 5

Views: 1117

Answers (4)

MJ Hufford
MJ Hufford

Reputation: 634

If you want to use their live site from code, I think you're talking about a screen scrape. I highly recommend looking into the HTML Agility Pack (available via nuget). This is going to allow you to read the DOM into your application and then interact with it however you please.

Upvotes: 3

penderi
penderi

Reputation: 9073

This could be a dumb answer but if you're trying to emulate a mouse click and find out if it's successful, why not use the Selenium Browser add-in to record your scripts / write' your own.

Then you can have a test suite to try against you're various different captchas.... hope this achieves what you're trying to do....

Upvotes: 2

gilly3
gilly3

Reputation: 91497

If you are able to execute JavaScript on that page directly, this code will do:

submitClick(document.getElementById("img").value, x, y, "tiled");

Otherwise, hit this url, substituting your own values for id, x, and y:

http://goldbach.cse.psu.edu/s/captcha/captcha_controller.php?id=87170&x=66&y=149&source=tiled

Parse the response - If your coordinates are correct, the response will contain "step 2". If not, the response will contain "step 1" and it will have a <div id="error">.

Upvotes: 8

Rob Allen
Rob Allen

Reputation: 2921

WebAii over at telerik has this feature. Here is some sample code i used at some point in the past customized for your situation. just put this in a class, left out the class container because it jacks up the formatting

protected static Manager _manager = null;
    protected static Manager _manager = null;
    protected Browser _main;
    protected Find _find;
public WebAiiAutomater() 
{
    if (_manager != null)
    {
        foreach (var broswer in _manager.Browsers)
        {
            broswer.Close();

        }
        return;
    }

    var settings = new Settings(BrowserType.InternetExplorer, @"c:\log\") { ClientReadyTimeout = 60 * 1000 };

    _manager = new Manager(settings);
    _manager.Start();
    _manager.LaunchNewBrowser();
    _manager.ActiveBrowser.AutoWaitUntilReady = true;

    _main = _manager.ActiveBrowser;
    _find = _main.Find;
    _main.NavigateTo(@"http://goldbach.cse.psu.edu/s/captcha/");
    //start looping over your alogrithm trying different x,y coords against ClickImage(x,y
}

public bool ClickImage(int x, int y)
{
    //var beginsearch = _find.ById("captcha_img"); //this should get you the image, but you don't need
    _manager.Desktop.Mouse.Click(MouseClickType.LeftClick, x, y);
    Thread.sleep(1000); //wait for postback - might be handled internally though
    var errordiv = _find.ById("error");

    return errordiv !=null;
}

Upvotes: 1

Related Questions