cpp-webdriver is a C++ binding for the Selenium REST API.
-
rapidjson ( http://code.google.com/p/rapidjson/)
-
libcurl4-openssl
-
cmake 2.6+
-
API: 50% (see API-STATUS.txt)
-
Doc: 0%
-
Unit Tests: 0% (Code Coverage: 0%)
Clone this repository with the following command:
git clone http://github.com/digination/cpp-webdriver
Then, create a new directory for building puproses:
mkdir cpp-webdriver-build
cd cpp-webdriver-build
cmake ../cpp-webdriver
make && make install.
#include <selenium/selenium.hpp>
#include <iostream>
#include <vector>
using std::string;
using std::cout;
using std::endl;
int main(int argc,char** argv) {
//creates new selenium object with the selenium entry page as argument.
Selenium* s = new Selenium("http://127.0.0.1:4444/wd/hub");
//creates new selenium session.
Session* sess = s->createSession(new Capabilities());
//goes to the google home page.
sess->url("http://www.google.com");
//gets all the links on the page
std::vector<Element*> links = sess->elements(new ElementQuery(ElementQuery::STRAT_TAG_NAME,"a"));
//displays the number of links on the google homepage
cout << "# of links:" << links.size() << endl;
}