Skip to content

Instantly share code, notes, and snippets.

@mikitebeka
Created December 1, 2009 01:07
Show Gist options
  • Select an option

  • Save mikitebeka/245959 to your computer and use it in GitHub Desktop.

Select an option

Save mikitebeka/245959 to your computer and use it in GitHub Desktop.
#include "stdafx.h"
#include <windows.h>
#include "webdriver.h"
#pragma comment (lib, "InternetExplorerDriver.lib")
#define CALL(func, error) \
if (func != SUCCESS) { \
fprintf(stderr, "error: %s\n", error); \
if (NULL != wd) { \
wdFreeDriver(wd); \
} \
return 1; \
}
int _tmain(int argc, _TCHAR* argv[])
{
wchar_t *script = L"(function() { return 1;})();";
if (2 == argc) {
script = argv[1];
}
WebDriver *wd = NULL;
CALL(wdNewDriverInstance(&wd), "create");
wdGet(wd, L"http://google.com");
ScriptArgs *args;
CALL(wdNewScriptArgs(&args, 0), "args");
ScriptResult* result;
CALL(wdExecuteScript(wd, script, args, &result), "execute");
CALL(wdFreeScriptArgs(args), "free args");
int type;
CALL(wdGetScriptResultType(result, &type), "type");
printf("%d\n", type);
CALL(wdFreeScriptResult(result), "free result");
CALL(wdFreeDriver(wd), "free driver");
printf("OK\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment