Giter VIP home page Giter VIP logo

webdriverxx's Introduction

Webdriver++

A C++ client library for Selenium Webdriver. You can use this library in any C++ project.

Install

mkdir build
cd build && cmake ..
sudo make && sudo make install

A quick example

Dependencies

You need to download and run selenium-server before run this example. http://www.seleniumhq.org/download/

#include <webdriverxx/webdriverxx.h>
using namespace webdriverxx;

int main() {
    WebDriver firefox = Start(Firefox());
    firefox
        .Navigate("http://google.com")
        .FindElement(ByCss("input[name=q]"))
        .SendKeys("Hello, world!")
        .Submit();
    return 0;    
}

Features

  • Chainable commands.
  • Value-like objects compatible with STL containers.
  • Header-only.
  • Lightweight dependencies:
  • Can be used with any testing framework.
  • Linux, Mac and Windows.
  • clang (3.4), GCC (4.6) and Visual Studio (2010).

More examples

#include <webdriverxx/webdriver.h> and using namespace webdriverxx are assumed in all examples.

Start browser

#include <webdriverxx/browsers/firefox.h>

WebDriver ff = Start(Firefox());
#include <webdriverxx/browsers/chrome.h>

WebDriver gc = Start(Chrome());
#include <webdriverxx/browsers/ie.h>

WebDriver ie = Start(InternetExplorer());

Use proxy

WebDriver ie = Start(InternetExplorer().SetProxy(
	SocksProxy("127.0.0.1:3128")
		.SetUsername("user")
		.SetPassword("12345")
		.SetNoProxyFor("custom.host")
	));
WebDriver ff = Start(Firefox().SetProxy(DirectConnection()));

Navigate browser

driver
	.Navigate("http://facebook.com")
	.Navigate("http://twitter.com")
	.Back()
	.Forward()
	.Refresh();

Find elements

// Throws exception if no match is found in the document
Element menu = driver.FindElement(ById("menu"));

// Returns empty vector if no such elements
// The search is performed inside the menu element
std::vector<Element> items = menu.FindElements(ByClass("item"));

Send keyboard input

// Sends text input or a shortcut to the element
driver.FindElement(ByTag("input")).SendKeys("Hello, world!");

// Sends text input or a shortcut to the active window
driver.SendKeys(Shortcut() << keys::Control << "t");

Execute Javascript

// Simple script, no parameters
driver.Execute("console.log('Hi there!')");

// A script with one parameter
driver.Execute("document.title = arguments[0]", JsArgs() << "Cowabunga!");

// A script with more than one parameter
driver.Execute("document.title = arguments[0] + '-' + arguments[1]",
		JsArgs() << "Beep" << "beep");

// Arrays or containers can also be used as parameters
const char* ss[] = { "Yabba", "dabba", "doo" };
driver.Execute("document.title = arguments[0].join(', ')", JsArgs() << ss);

// Even an Element can be passed to a script
auto element = driver.FindElement(ByTag("input"));
driver.Execute("arguments[0].value = 'That was nuts!'", JsArgs() << element);

Get something from Javascript

// Scalar types
auto title = driver.Eval<std::string>("return document.title")
auto number = driver.Eval<int>("return 123");
auto another_number = driver.Eval<double>("return 123.5");
auto flag = driver.Eval<bool>("return true");

// Containers (all std::back_inserter compatible)
std::vector<std::string> v = driver.Eval<std::vector<std::string>>(
		"return [ 'abc', 'def' ]"
		);

// Elements!
Element document_element = driver.Eval<Element>("return document.documentElement");

Wait implicitly for asynchronous operations

driver.SetImplicitTimeoutMs(5000);

// Should poll the DOM for 5 seconds before throwing an exception.
auto element = driver.FindElement(ByName("async_element"));

Wait explicitly for asynchronous operations

#include <webdriverxx/wait.h>

auto find_element = [&]{ return driver.FindElement(ById("async_element")); };
Element element = WaitForValue(find_element);
#include <webdriverxx/wait.h>

auto element_is_selected = [&]{
	return driver.FindElement(ById("asynchronously_loaded_element")).IsSelected();
	};
WaitUntil(element_is_selected);

Use matchers from Google Mock for waiting

#define WEBDRIVERXX_ENABLE_GMOCK_MATCHERS
#include <webdriverxx/wait_match.h>

driver.Navigate("http://initial_url.host.net");
auto url = [&]{ return driver.GetUrl(); };
using namespace ::testing;
auto final_url = WaitForMatch(url, HasSubstr("some_magic"));

Testing with real browsers

Prerequisites:

selenium-server -p 4444 &
./webdriverxx --browser=<firefox|chrome|...>

Advanced topics

Unicode

The library is designed to be encoding-agnostic. It doesn't make any assumptions about encodings. All strings are transferred as is, without modifications.

The WebDriver protocol is based on UTF-8, so all strings passed to the library/received from the library should be/are encoded using UTF-8.

Thread safety

  • Webdriver++ objects are not thread safe. It is not safe to use neither any single object nor different objects obtained from a single WebDriver concurrently without synchronization. On the other side, Webdriver++ objects don't use global variables so it is OK to use different instances of WebDriver in different threads.

  • The CURL library should be explicitly initialized if several WebDrivers are used from multiple threads. Call curl_global_init(CURL_GLOBAL_ALL); from <curl/curl.h> once per process before using this library.

Use common capabilities for all browsers

Capabilities common;
common.SetProxy(DirectConnection());
auto ff = Start(Firefox(common));
auto ie = Start(InternetExplorer(common));
auto gc = Start(Chrome(common));

Use required capabilities

Capabilities required = /* ... */;
auto ff = Start(Firefox(), required);

Use custom URL for connecting to WebDriver

const char* url = "http://localhost:4444/wd/hub/";

auto ff = Start(Firefox(), url);

// or
auto ff = Start(Firefox(), Capabilities() /* required */, url);

Transfer objects between C++ and Javascript

namespace custom {

struct Object {
	std::string string;
	int number;
};

// Conversion functions should be in the same namespace as the object
picojson::value CustomToJson(const Object& value) {
	return JsonObject()
		.Set("string", value.string)
		.Set("number", value.number);
}

void CustomFromJson(const picojson::value& value, Object& result) {
	assert(value.is<picojson::object>());
	result.string = FromJson<std::string>(value.get("string"));
	result.number = FromJson<int>(value.get("number"));
}

} // namespace custom

custom::Object o1 = { "abc", 123 };
driver.Execute("var o1 = arguments[0];", JsArgs() << o1);
custom::Object o1_copy = driver.Eval<custom::Object>("return o1");
custom::Object o2 = driver.Eval<custom::Object>("return { string: 'abc', number: 123 }");

Copyright © 2014 Sergey Kogan. Licensed under The MIT license.

webdriverxx's People

Contributors

durdyev avatar sekogan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webdriverxx's Issues

Cannot setup page load timeout.

Cannot setup timeout of page loading, what i doing wrong?

` this->управление = new WebDriver(Firefox(), Capabilities(), kDefaultWebDriverUrl);

/** namespace timeout {

  typedef const char* Type;

  Type const Implicit = "implicit";
  Type const PageLoad = "page load";
  Type const Script = "script";

  } // namespace timeout */

управление->SetTimeoutMs(timeout::PageLoad, 1);`

stuck on

управление->Navigate(адрес);

after page loaded waiting all timeout on internal some value.

Exception handler

First thing, amazing project. Just amazing. You saved me a TON of time.

Is there a way to catch/handle these sort of exceptions ? https://prnt.sc/spbhlg

This happens when I try to use proxies, and the weird thing is that eventually the browser loads.

ChromeOptions headless

How can I start chrome as headless? In java it can be possible with ChromeOptions but I can't see that kind of function.

Curl problem

I have an error that says that curl.h from curl is undefined

Can't compile the example, server running on 4444

[erik@codebase New Folder]$ g++ main.cpp -o run
/usr/bin/ld: /tmp/ccyPYgcD.o: in function webdriverxx::detail::HttpHeaders::~HttpHeaders()': main.cpp:(.text._ZN11webdriverxx6detail11HttpHeadersD2Ev[_ZN11webdriverxx6detail11HttpHeadersD5Ev]+0x17): undefined reference to curl_slist_free_all'
/usr/bin/ld: /tmp/ccyPYgcD.o: in function webdriverxx::detail::HttpHeaders::Add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': main.cpp:(.text._ZN11webdriverxx6detail11HttpHeaders3AddERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_[_ZN11webdriverxx6detail11HttpHeaders3AddERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_]+0x95): undefined reference to curl_slist_append'
/usr/bin/ld: /tmp/ccyPYgcD.o: in function webdriverxx::detail::HttpRequest::Execute()': main.cpp:(.text._ZN11webdriverxx6detail11HttpRequest7ExecuteEv[_ZN11webdriverxx6detail11HttpRequest7ExecuteEv]+0x3a): undefined reference to curl_easy_reset'
/usr/bin/ld: main.cpp:(.text._ZN11webdriverxx6detail11HttpRequest7ExecuteEv[_ZN11webdriverxx6detail11HttpRequest7ExecuteEv]+0x216): undefined reference to curl_easy_perform' /usr/bin/ld: /tmp/ccyPYgcD.o: in function webdriverxx::detail::HttpRequest::GetHttpCode() const':
main.cpp:(.text._ZNK11webdriverxx6detail11HttpRequest11GetHttpCodeEv[_ZNK11webdriverxx6detail11HttpRequest11GetHttpCodeEv]+0x4f): undefined reference to curl_easy_getinfo' /usr/bin/ld: main.cpp:(.text._ZNK11webdriverxx6detail11HttpRequest11GetHttpCodeEv[_ZNK11webdriverxx6detail11HttpRequest11GetHttpCodeEv]+0xf3): undefined reference to curl_easy_strerror'
/usr/bin/ld: /tmp/ccyPYgcD.o: in function webdriverxx::detail::HttpConnection::~HttpConnection()': main.cpp:(.text._ZN11webdriverxx6detail14HttpConnectionD2Ev[_ZN11webdriverxx6detail14HttpConnectionD5Ev]+0x35): undefined reference to curl_easy_cleanup'
/usr/bin/ld: /tmp/ccyPYgcD.o: in function webdriverxx::detail::HttpConnection::InitCurl()': main.cpp:(.text._ZN11webdriverxx6detail14HttpConnection8InitCurlEv[_ZN11webdriverxx6detail14HttpConnection8InitCurlEv]+0x1e): undefined reference to curl_easy_init'
/usr/bin/ld: /tmp/ccyPYgcD.o: in function void webdriverxx::detail::HttpRequest::SetOption<char const*>(CURLoption, char const* const&) const': main.cpp:(.text._ZNK11webdriverxx6detail11HttpRequest9SetOptionIPKcEEv10CURLoptionRKT_[_ZNK11webdriverxx6detail11HttpRequest9SetOptionIPKcEEv10CURLoptionRKT_]+0x57): undefined reference to curl_easy_setopt'
/usr/bin/ld: main.cpp:(.text.ZNK11webdriverxx6detail11HttpRequest9SetOptionIPKcEEv10CURLoptionRKT[ZNK11webdriverxx6detail11HttpRequest9SetOptionIPKcEEv10CURLoptionRKT]+0x12e): undefined reference to curl_easy_strerror' /usr/bin/ld: /tmp/ccyPYgcD.o: in function void webdriverxx::detail::HttpRequest::SetOption<unsigned long ()(void, unsigned long, unsigned long, void*)>(CURLoption, unsigned long (* const&)(void*, unsigned long, unsigned long, void*)) const':
main.cpp:(.text.ZNK11webdriverxx6detail11HttpRequest9SetOptionIPFmPvmmS3_EEEv10CURLoptionRKT[ZNK11webdriverxx6detail11HttpRequest9SetOptionIPFmPvmmS3_EEEv10CURLoptionRKT]+0x57): undefined reference to curl_easy_setopt' /usr/bin/ld: main.cpp:(.text._ZNK11webdriverxx6detail11HttpRequest9SetOptionIPFmPvmmS3_EEEv10CURLoptionRKT_[_ZNK11webdriverxx6detail11HttpRequest9SetOptionIPFmPvmmS3_EEEv10CURLoptionRKT_]+0x12e): undefined reference to curl_easy_strerror'
/usr/bin/ld: /tmp/ccyPYgcD.o: in function void webdriverxx::detail::HttpRequest::SetOption<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*>(CURLoption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >* const&) const': main.cpp:(.text._ZNK11webdriverxx6detail11HttpRequest9SetOptionIPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEv10CURLoptionRKT_[_ZNK11webdriverxx6detail11HttpRequest9SetOptionIPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEv10CURLoptionRKT_]+0x57): undefined reference to curl_easy_setopt'
/usr/bin/ld: main.cpp:(.text.ZNK11webdriverxx6detail11HttpRequest9SetOptionIPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEv10CURLoptionRKT[ZNK11webdriverxx6detail11HttpRequest9SetOptionIPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEv10CURLoptionRKT]+0x12e): undefined reference to curl_easy_strerror' /usr/bin/ld: /tmp/ccyPYgcD.o: in function void webdriverxx::detail::HttpRequest::SetOption<char () [256]>(CURLoption, char ( const&) [256]) const':
main.cpp:(.text.ZNK11webdriverxx6detail11HttpRequest9SetOptionIPA256_cEEv10CURLoptionRKT[ZNK11webdriverxx6detail11HttpRequest9SetOptionIPA256_cEEv10CURLoptionRKT]+0x57): undefined reference to curl_easy_setopt' /usr/bin/ld: main.cpp:(.text._ZNK11webdriverxx6detail11HttpRequest9SetOptionIPA256_cEEv10CURLoptionRKT_[_ZNK11webdriverxx6detail11HttpRequest9SetOptionIPA256_cEEv10CURLoptionRKT_]+0x12e): undefined reference to curl_easy_strerror'
/usr/bin/ld: /tmp/ccyPYgcD.o: in function void webdriverxx::detail::HttpRequest::SetOption<curl_slist*>(CURLoption, curl_slist* const&) const': main.cpp:(.text._ZNK11webdriverxx6detail11HttpRequest9SetOptionIP10curl_slistEEv10CURLoptionRKT_[_ZNK11webdriverxx6detail11HttpRequest9SetOptionIP10curl_slistEEv10CURLoptionRKT_]+0x57): undefined reference to curl_easy_setopt'
/usr/bin/ld: main.cpp:(.text.ZNK11webdriverxx6detail11HttpRequest9SetOptionIP10curl_slistEEv10CURLoptionRKT[ZNK11webdriverxx6detail11HttpRequest9SetOptionIP10curl_slistEEv10CURLoptionRKT]+0x12e): undefined reference to curl_easy_strerror' /usr/bin/ld: /tmp/ccyPYgcD.o: in function void webdriverxx::detail::HttpRequest::SetOption<char [7]>(CURLoption, char const (&) [7]) const':
main.cpp:(.text.ZNK11webdriverxx6detail11HttpRequest9SetOptionIA7_cEEv10CURLoptionRKT[ZNK11webdriverxx6detail11HttpRequest9SetOptionIA7_cEEv10CURLoptionRKT]+0x54): undefined reference to curl_easy_setopt' /usr/bin/ld: main.cpp:(.text._ZNK11webdriverxx6detail11HttpRequest9SetOptionIA7_cEEv10CURLoptionRKT_[_ZNK11webdriverxx6detail11HttpRequest9SetOptionIA7_cEEv10CURLoptionRKT_]+0x12b): undefined reference to curl_easy_strerror'
/usr/bin/ld: /tmp/ccyPYgcD.o: in function void webdriverxx::detail::HttpRequest::SetOption<long>(CURLoption, long const&) const': main.cpp:(.text._ZNK11webdriverxx6detail11HttpRequest9SetOptionIlEEv10CURLoptionRKT_[_ZNK11webdriverxx6detail11HttpRequest9SetOptionIlEEv10CURLoptionRKT_]+0x57): undefined reference to curl_easy_setopt'
/usr/bin/ld: main.cpp:(.text.ZNK11webdriverxx6detail11HttpRequest9SetOptionIlEEv10CURLoptionRKT[ZNK11webdriverxx6detail11HttpRequest9SetOptionIlEEv10CURLoptionRKT]+0x12e): undefined reference to curl_easy_strerror' /usr/bin/ld: /tmp/ccyPYgcD.o: in function void webdriverxx::detail::HttpRequest::SetOption(CURLoption, unsigned long const&) const':
main.cpp:(.text.ZNK11webdriverxx6detail11HttpRequest9SetOptionImEEv10CURLoptionRKT[ZNK11webdriverxx6detail11HttpRequest9SetOptionImEEv10CURLoptionRKT]+0x57): undefined reference to curl_easy_setopt' /usr/bin/ld: main.cpp:(.text._ZNK11webdriverxx6detail11HttpRequest9SetOptionImEEv10CURLoptionRKT_[_ZNK11webdriverxx6detail11HttpRequest9SetOptionImEEv10CURLoptionRKT_]+0x12e): undefined reference to curl_easy_strerror'
/usr/bin/ld: /tmp/ccyPYgcD.o: in function void webdriverxx::detail::HttpRequest::SetOption<unsigned long (void*, unsigned long, unsigned long, void*)>(CURLoption, unsigned long ( const&)(void*, unsigned long, unsigned long, void*)) const': main.cpp:(.text._ZNK11webdriverxx6detail11HttpRequest9SetOptionIFmPvmmS3_EEEv10CURLoptionRKT_[_ZNK11webdriverxx6detail11HttpRequest9SetOptionIFmPvmmS3_EEEv10CURLoptionRKT_]+0x54): undefined reference to curl_easy_setopt'
/usr/bin/ld: main.cpp:(.text.ZNK11webdriverxx6detail11HttpRequest9SetOptionIFmPvmmS3_EEEv10CURLoptionRKT[ZNK11webdriverxx6detail11HttpRequest9SetOptionIFmPvmmS3_EEEv10CURLoptionRKT]+0x12b): undefined reference to curl_easy_strerror' /usr/bin/ld: /tmp/ccyPYgcD.o: in function void webdriverxx::detail::HttpRequest::SetOptionwebdriverxx::detail::HttpPostRequest*(CURLoption, webdriverxx::detail::HttpPostRequest* const&) const':
main.cpp:(.text.ZNK11webdriverxx6detail11HttpRequest9SetOptionIPNS0_15HttpPostRequestEEEv10CURLoptionRKT[ZNK11webdriverxx6detail11HttpRequest9SetOptionIPNS0_15HttpPostRequestEEEv10CURLoptionRKT]+0x57): undefined reference to curl_easy_setopt' /usr/bin/ld: main.cpp:(.text._ZNK11webdriverxx6detail11HttpRequest9SetOptionIPNS0_15HttpPostRequestEEEv10CURLoptionRKT_[_ZNK11webdriverxx6detail11HttpRequest9SetOptionIPNS0_15HttpPostRequestEEEv10CURLoptionRKT_]+0x12e): undefined reference to curl_easy_strerror'

can't compile on windows 10 using Mingw32 7.3.0 or visual studio 2017

Hello,
I download the project as a zip file and extract it in a folder, run the cmake and generate the files then run the mingw32-make, it make the step of downloading the curl project then it give me an error which the last part from it in the consol is

CMake Error: File D:/build/webdriver/build/test/curl/src/curl_project/cmake_uninstall.cmake.in does not exist.
CMake Error at CMakeLists.txt:1343 (configure_file):
  configure_file Problem configuring file


-- Configuring incomplete, errors occurred!
See also "D:/build/webdriver/build/test/curl/src/curl_project-build/CMakeFiles/CMakeOutput.log".
See also "D:/build/webdriver/build/test/curl/src/curl_project-build/CMakeFiles/CMakeError.log".
mingw32-make[2]: *** [test\CMakeFiles\curl_project.dir\build.make:109: test/curl/src/curl_project-stamp/curl_project-configure] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:96: test/CMakeFiles/curl_project.dir/all] Error 2
mingw32-make: *** [Makefile:140: all] Error 2

and the files generated which explained the error
the CMakeError.log
the CMakeOutput.log
any help please on how can i make it run on windows?
Thanks in advance.

`make` must be run as root

The install instructions are not quite accurate: make apparently must be run as root in order to compile webdriverxx.

Here I have pasted the full build output. I git clone the repository, create a build directory and enter it, run cmake .., and then make, which progresses a little and then exits with an error as it tries to copy a file into /usr/local/lib.

lol@foldingmachinebox:~$ git clone [email protected]:durdyev/webdriverxx.git
Cloning into 'webdriverxx'...
remote: Counting objects: 1578, done.        
remote: Total 1578 (delta 0), reused 0 (delta 0), pack-reused 1578        
Receiving objects: 100% (1578/1578), 260.41 KiB | 0 bytes/s, done.
Resolving deltas: 100% (1077/1077), done.
lol@foldingmachinebox:~$ cd webdriverxx/
lol@foldingmachinebox:~/webdriverxx$ mkdir build
lol@foldingmachinebox:~/webdriverxx$ cd build/
lol@foldingmachinebox:~/webdriverxx/build$ cmake ..
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test COMPILER_SUPPORTS_CXX11
-- Performing Test COMPILER_SUPPORTS_CXX11 - Success
-- Performing Test COMPILER_SUPPORTS_CXX0X
-- Performing Test COMPILER_SUPPORTS_CXX0X - Success
-- Found CURL: /usr/lib/i386-linux-gnu/libcurl.so (found version "7.52.1") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lol/webdriverxx/build
lol@foldingmachinebox:~/webdriverxx/build$ make
Scanning dependencies of target googletest
[  1%] Creating directories for 'googletest'
[  3%] Performing download step (git clone) for 'googletest'
Cloning into 'googletest'...
Already on 'master'
Your branch is up-to-date with 'origin/master'.
[  5%] No patch step for 'googletest'
[  7%] No update step for 'googletest'
[  9%] Performing configure step for 'googletest'
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python (found version "2.7.13") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lol/webdriverxx/build/test/googletest/src/googletest-build
[ 11%] Performing build step for 'googletest'
Scanning dependencies of target gtest
[ 12%] Building CXX object googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 25%] Linking CXX static library libgtest.a
[ 25%] Built target gtest
Scanning dependencies of target gmock
[ 37%] Building CXX object googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o
[ 50%] Linking CXX static library libgmock.a
[ 50%] Built target gmock
Scanning dependencies of target gmock_main
[ 62%] Building CXX object googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o
[ 75%] Linking CXX static library libgmock_main.a
[ 75%] Built target gmock_main
Scanning dependencies of target gtest_main
[ 87%] Building CXX object googlemock/gtest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
[100%] Linking CXX static library libgtest_main.a
[100%] Built target gtest_main
[ 13%] Performing install step for 'googletest'
[ 25%] Built target gtest
[ 50%] Built target gmock
[ 75%] Built target gmock_main
[100%] Built target gtest_main
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/libgmock.a
CMake Error at googlemock/cmake_install.cmake:36 (file):
  file INSTALL cannot copy file
  "/home/lol/webdriverxx/build/test/googletest/src/googletest-build/googlemock/libgmock.a"
  to "/usr/local/lib/libgmock.a".
Call Stack (most recent call first):
  cmake_install.cmake:37 (include)


Makefile:72: recipe for target 'install' failed
make[3]: *** [install] Error 1
test/CMakeFiles/googletest.dir/build.make:73: recipe for target 'test/googletest/src/googletest-stamp/googletest-install' failed
make[2]: *** [test/googletest/src/googletest-stamp/googletest-install] Error 2
CMakeFiles/Makefile2:164: recipe for target 'test/CMakeFiles/googletest.dir/all' failed
make[1]: *** [test/CMakeFiles/googletest.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

Fails to compile on MacOS

The program fails to compile on MacOS with the errors below. It seems the googletest is not compiled with the flag -std=c++11. Additionally the googletest include and lib directories are not properly set up for the compile paths.

In case someone else is having similar issues, I fixed this issue by updating the GoogleTest in the test/CMakeLists.txt file as follows:

# Google test
externalproject_add(googletest
                PREFIX googletest
                GIT_REPOSITORY https://github.com/google/googletest
                UPDATE_COMMAND ""
                CMAKE_ARGS
                        -DCMAKE_CXX_FLAGS="-std=c++11"
)
externalproject_get_property(googletest source_dir binary_dir)
include_directories("${source_dir}/googletest/include")
include_directories("${source_dir}/googlemock/include")
link_directories("${binary_dir}/lib")
list(APPEND DEPS googletest)
list(APPEND LIBS gtest gmock)
Scanning dependencies of target googletest
[  1%] Creating directories for 'googletest'
[  3%] Performing download step (git clone) for 'googletest'
Cloning into 'googletest'...
Already on 'master'
Your branch is up-to-date with 'origin/master'.
[  5%] No patch step for 'googletest'
[  7%] No update step for 'googletest'
[  9%] Performing configure step for 'googletest'
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python (found version "2.7.16") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /build/test/googletest/src/googletest-build
[ 11%] Performing build step for 'googletest'
Scanning dependencies of target gtest
[ 12%] Building CXX object googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
In file included from /build/test/googletest/src/googletest/googletest/src/gtest-all.cc:38:
In file included from /build/test/googletest/src/googletest/googletest/include/gtest/gtest.h:62:
In file included from /build/test/googletest/src/googletest/googletest/include/gtest/internal/gtest-internal.h:40:
/build/test/googletest/src/googletest/googletest/include/gtest/internal/gtest-port.h:842:12: error: no member named
      'make_tuple' in namespace 'std'
using std::make_tuple;
      ~~~~~^
/build/test/googletest/src/googletest/googletest/include/gtest/internal/gtest-port.h:843:12: error: no member named 'tuple' in
      namespace 'std'
using std::tuple;
      ~~~~~^
/build/test/googletest/src/googletest/googletest/include/gtest/internal/gtest-port.h:922:3: error: deleted function
      definitions are a C++11 extension [-Werror,-Wc++11-extensions]
  GTEST_DISALLOW_ASSIGN_(RE);
  ^

Building on Windows

I am having a myriad of issues building this on Windows 10. I've had no issues building & using under Debian Buster - I've spent hours & hours trying to build on Windows 10. What steps should I be following to build & install this on Windows? Unless I've done something wrong, I have the lightweight dependencies installed completely & am just needing to finish building & installing webdriverxx. I'm using Windows 10 v.20H2 b.19042.1110 & MinGW GCC/G++.

The steps I've performed:

  1. git clone https://github.com/durdyev/webdriverxx.git
  2. cd webdriverxx
  3. mkdir build && cd build && cmake -G "MinGW Makefiles" ..
  4. mingw32-make all

This is where things start to break. After executing step 4, I receive an error:

%userprofile%/Downloads/webdriverxx/build/test/curl/src/curl_project/cmake_uninstall.cmake.in does not exist.
See also "%userprofile%/Downloads/webdriverxx/build/test/curl/src/curl_project-build/CMakeFiles/CMakeOutput.log".
See also "%userprofile%/Downloads/webdriverxx/build/test/curl/src/curl_project-build/CMakeFiles/CMakeError.log".

Is there something I'm doing incorrectly that is causing this issue? Any help would be appreciated. Thank you.

Google Test problem?

The problem is here:

TEST(WaitForMatch, CanUseGMockMatchers) {
using namespace ::testing;
ASSERT_EQ(123, WaitForMatch([]{ return 123; }, Eq(123)));
ASSERT_EQ(123, WaitForMatch([]{ return 123; }, 123));
ASSERT_EQ("abc", WaitForMatch([]{ return std::string("abc"); }, "abc"));
ASSERT_EQ("abc", WaitForMatch([]{ return std::string("abc"); }, Eq("abc")));
ASSERT_EQ(123, WaitForMatch([]{ return 123; }, _));
ASSERT_EQ(123, WaitForMatch([]{ return 123; }, An()));
std::vector v(1, 123);
ASSERT_EQ(v, WaitForMatch([&v]{ return v; }, Contains(123)));
ASSERT_EQ(v, WaitForMatch([&v]{ return v; }, Not(Contains(456))));
Duration timeout = 0;
ASSERT_THROW(WaitForMatch([&v]{ return v; }, Not(Contains(123)), timeout), WebDriverException);
}

in the wait_match_test.cpp

Functions An(), Contains() and Not() are not defined.

Do anyone have the idea how to fix this?

i cant build on windows 10, microsoft studio 2017

mkdir web2
cd web2
git clone https://github.com/durdyev/webdriverxx
cd webdriverxx
mkdir build
cd build
cmake ..
everything's ok. but then Microsoft Visual Studio 2017 cant build it.

Severity Code Description Project File Line Suppression State Error MSB3073 The command "setlocal [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 The command "setlocal [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 "C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 if %errorlevel% neq 0 goto :cmEnd [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 :cmEnd [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 :cmErrorLevel [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 exit /b %1 [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 :cmDone [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 if %errorlevel% neq 0 goto :VCEnd [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 :VCEnd" exited with code 1. [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 "C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 if %errorlevel% neq 0 goto :cmEnd [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 :cmEnd [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 :cmErrorLevel [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 exit /b %1 [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 :cmDone [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 if %errorlevel% neq 0 goto :VCEnd [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB3073 :VCEnd" exited with code 1. [C:\web2\webdriverxx\build\test\googletest\src\googletest-build\install.vcxproj] googletest C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133 Error MSB6006 "cmd.exe" exited with code 1. curl_project C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 171 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\capabilities_test.cpp 2 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\conversions_test.cpp 2 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\resource_test.cpp 4 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\shared_test.cpp 2 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\to_string_test.cpp 2 Error C1083 Cannot open include file: 'gmock/gmock-matchers.h': No such file or directory webdriverxx c:\web2\webdriverxx\include\webdriverxx\wait_match.h 10 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\wait_test.cpp 2 Error C1083 Cannot open include file: 'gtest/gtest.h': No such file or directory webdriverxx c:\web2\webdriverxx\test\environment.h 6

Visual Studio

What libraries to include in the directories and what should be the lib folders

Installing Latest gmock and gtest Mandatory?

I already have gmock and gtest intalled via yum on my machine, but it seems like make script insists to git clone and then install:
$ make
Scanning dependencies of target googletest
[ 1%] Creating directories for 'googletest'
[ 3%] Performing download step (git clone) for 'googletest'
Cloning into 'googletest'...
Already on 'master'
[ 5%] No patch step for 'googletest'
[ 7%] No update step for 'googletest'
[ 9%] Performing configure step for 'googletest'
-- The C compiler identification is GNU 7.2.1
-- The CXX compiler identification is GNU 7.2.1
-- Check for working C compiler: /opt/rh/devtoolset-7/root/usr/bin/cc
-- Check for working C compiler: /opt/rh/devtoolset-7/root/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /opt/rh/devtoolset-7/root/usr/bin/c++
-- Check for working CXX compiler: /opt/rh/devtoolset-7/root/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python (found version "2.7.5")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hc/Downloads/webdriverxx-master/build/test/googletest/src/googletest-build
[ 11%] Performing build step for 'googletest'
Scanning dependencies of target gtest
[ 12%] Building CXX object googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 25%] Linking CXX static library ../../lib/libgtest.a
[ 25%] Built target gtest
Scanning dependencies of target gmock
[ 37%] Building CXX object googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o
[ 50%] Linking CXX static library ../lib/libgmock.a
[ 50%] Built target gmock
Scanning dependencies of target gmock_main
[ 62%] Building CXX object googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o
[ 75%] Linking CXX static library ../lib/libgmock_main.a
[ 75%] Built target gmock_main
Scanning dependencies of target gtest_main
[ 87%] Building CXX object googlemock/gtest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
[100%] Linking CXX static library ../../lib/libgtest_main.a
[100%] Built target gtest_main
[ 13%] Performing install step for 'googletest'
[ 25%] Built target gtest
[ 50%] Built target gmock
[ 75%] Built target gmock_main
[100%] Built target gtest_main
Install the project...
-- Install configuration: ""
-- Up-to-date: /usr/local/include
CMake Error at googlemock/cmake_install.cmake:41 (file):
file INSTALL cannot set permissions on "/usr/local/include"
Call Stack (most recent call first):
cmake_install.cmake:42 (include)

make[3]: *** [install] Error 1
make[2]: *** [test/googletest/src/googletest-stamp/googletest-install] Error 2
make[1]: *** [test/CMakeFiles/googletest.dir/all] Error 2
make: *** [all] Error 2

Probably not a good idea to overwrite packages installed via yum?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.