Сhromedriver: how to add support of Chromium-based browsers Сhromedriver: how to add support of Chromium-based browsers selenium selenium

Сhromedriver: how to add support of Chromium-based browsers


TL;DR: Use Selenium + Codeception (or any other chrome-supported framework), add to configuration a special enviroment for "non-valid" browser as Sputnik, wherein path to binary is equivalent to your chrome-binary. Recompile chromedriver from chromium-project after removing one of unnecessary for us condition of checking the browser version, pre-install the following software kits: Visual Studio (С++, wdk+sdk+mfc+atl), depot_tools, Perl, Python2+Pywin32 and after this need to fix one of snag in Windows Kits source code, because of which there is no possibility to compile the project via ninja.

Useful materials:

[English]: http://www.chromium.org/developers/how-tos/get-the-code http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up

[Russian]: https://gist.github.com/oshatrk/0d454018e720b44b45d3e9679da6a98a https://habr.com/company/jugru/blog/347024/

This instruction is provided for Windows 10.

Download the latest version of original Chromedriver and put in C:/Windows): https://chromedriver.storage.googleapis.com/index.html — is useful for debugging non-obvious problems that may arise when running autotests in an invalid / valid browser

You must use only the standard command line (cmd), otherwise you will encounter a number of unobvious errors like as "% filename%: no such file or directory."

Add settings to git:

$ git config --global user.name "%USERNAME%"$ git config --global user.email "%EMAIL%"$ git config --global core.autocrlf false$ git config --global core.filemode false$ git config --global branch.autosetuprebase always 

Install Visual Studio (for C++), select the latest SDK packages, MFC- and ATL- support packages, Debugging Tools For Windows, Windows Driver Kit (WDK) and depot tools.

Download Chromium from repo https://github.com/chromium/chromium and prepare the project for compilation:

To save space (~ 10GB), it is better to execute the first line with flag: fetch --no-history chromium.

d:\chromium> fetch chromiumd:\chromium> mkdir srcd:\chromium> cd srcd:\chromium\src> gclient syncd:\chromium\src> gn gen out/Default

If you will encounter similar errors in the process of executing gn-commands:

ninja: error: loading 'build.ninja': no such file or directoryninja: error: loading 'build.ninja': ═х єфрхЄё эрщЄш єърчрээ√щ Їрщы.

— most likely a problem either in conflicting installed versions of Win10 SDK, or due to the lack of WDK / Debugging Tools For Windows.

Trying to autotests executing. At the beginning, check for a bunch of Selenium + Codeception, that autotests are really successfully executed in the Chrome in the absence of conflicts with the Chromedriver. For example, Chromedriver 2.41 supports Chrome v67-69, and in the end will be able to support Sputnik v3.5.2152.0 gostssl.

Once we are convinced of the initial working capacity set up the Sputnik browser call (so far unstable of the autotest code execution): create env-section in yml-config or write to the standard config section the Chrome to which set the path to Sputnik:

 modules:  enabled: [WebDriver, WebHelper, Asserts]  config:    WebDriver:      browser: chrome      capabilities:      chromeOptions:        args: [--remote-debugging-port=9222]        binary: 'C:/Program Files (x86)/Sputnik/Sputnik/Application/browser.exe'    #window_size: 1200x768 is not supported for Sputnik

The declared flag --remote-debugging-port=9222 is needed to avoid the error [Facebook\WebDriver\Exception\UnknownServerException] unknown error: Devtools port number file contents \<50250> were in an unexpected format.I warn you in advance that you should not use the window_size parameter, since Chromium does not support it, otherwise we will encounter an error: [Facebook\WebDriver\Exception\UnknownServerException] unknown error: unhandled inspector error: {"code":-32601,"message":"'Browser.getWindowForTarget' wasn't found"}. Don't try to overwrite product information in accordance with Chrome in the Sputnik version, since in this case the executable will become invalid, when try to start you will see the error "Could not start the application because its parallel configuration is incorrect", and when you run the autotests we will encounter the error: [Facebook\WebDriver\Exception\UnknownServerException] unknown error: Failed to create a Chrome process.When running autotests through Sputnik on current step of instruction should see this error: [Facebook \ WebDriver \ Exception \ UnknownServerException] unknown error: unrecognized Chrome version: SputnikBrowser / 3.5.2152.0 (GOST).— is solved by recompiling Chromedriver, after removing the check for the browser version.

Check that you can actually compile Chromedriver from source:

d:\chromium\src> ninja -C out/Default chromedriver

if everything is ok, then the file will be located here:

d:\chromium\src\out\Default\chromedriver.exe

Check that with this compiled version of chromedriver, the AutoTests are really successfully executed in the Chrome browser, after putting the updated chromedriver.exe in C:/Windows.

Edit line in the file chromedriver \ chrome \ browser_info.cc: 128, for ignoring the mismatch of the browser version:

return error;

replace error status to successful status: (don't tell anyone I gave you this solution):

return Status(kOk);

Compile the Chromedriver again, after deleting the contents of the Default folder. And also in case of errors during compilation, you should clear the folder before the next compilation, otherwise the compiled version will most likely be broken.

If the compilation was successful, then put the updated chromedriver.exe in C:/Windows and first verify that the autotests are still successfully executed in the Chrome browser: after successful executing check the operation in the Sputnik.

If you encounter the following error log during compilation:

[3281/4416] CXX obj/ui/gfx/gfx/font_fallback_win.objFAILED: obj/ui/gfx/gfx/font_fallback_win.obj../../third_party/llvm-build/Release+Asserts/bin/clang-cl.exe /nologo /showIncludes "-imsvc..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\ATLMFC\include" "-imsvc..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\include" "-imsvc..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-imsvc..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-imsvc..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-imsvc..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-imsvc..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" -DGFX_IMPLEMENTATION -DV8_DEPRECATION_WARNINGS -DUSE_AURA=1 -DNO_TCMALLOC -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DOFFICIAL_BUILD -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED "-DCR_CLANG_REVISION=\"338452-2\"" -D_HAS_NODISCARD -D_HAS_EXCEPTIONS=0 -D__STD_C -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -D_ATL_NO_OPENGL -D_WINDOWS -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DPSAPI_VERSION=1 -DWIN32 -D_SECURE_ATL -D_USING_V110_SDK71_ -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_UNICODE -DUNICODE -DNTDDI_VERSION=0x0A000002 -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DWEBP_EXTERN=extern -DSK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS -DSK_HAS_PNG_LIBRARY -DSK_HAS_WEBP_LIBRARY -DSK_HAS_JPEG_LIBRARY -DSK_SUPPORT_GPU=1 "-DSK_GPU_WORKAROUNDS_HEADER=\"gpu/config/gpu_driver_bug_workaround_autogen.h\"" -DGR_GL_FUNCTION_TYPE=__stdcall -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DUCHAR_TYPE=wchar_t "-DFT_CONFIG_CONFIG_H=\"freetype-custom-config/ftconfig.h\"" "-DFT_CONFIG_MODULES_H=\"freetype-custom-config/ftmodule.h\"" "-DFT_CONFIG_OPTIONS_H=\"freetype-custom-config/ftoption.h\"" -DPDFIUM_REQUIRED_MODULES -DCHROMIUM_RESTRICT_VISIBILITY -I../.. -Igen -I../../third_party/libwebp/src -I../../skia/config -I../../skia/ext -I../../third_party/skia/include/c -I../../third_party/skia/include/config -I../../third_party/skia/include/core -I../../third_party/skia/include/effects -I../../third_party/skia/include/encode -I../../third_party/skia/include/gpu -I../../third_party/skia/include/images -I../../third_party/skia/include/lazy -I../../third_party/skia/include/pathops -I../../third_party/skia/include/pdf -I../../third_party/skia/include/pipe -I../../third_party/skia/include/ports -I../../third_party/skia/include/utils -I../../third_party/skia/src/gpu -I../../third_party/skia/src/sksl -I../../third_party/skia/modules/skottie/include -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -I../../third_party/ced/src -I../../third_party/zlib -I../../third_party/freetype/include -I../../third_party/freetype/src/include -I../../third_party/harfbuzz-ng/src/src /utf-8 /X -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -fcomplete-member-pointers /Gy /FS /bigobj /d2FastFail /Zc:sizedDealloc- -fmsc-version=1911 -m64 /Brepro /W4 -Wimplicit-fallthrough -Wthread-safety /WX /wd4091 /wd4127 /wd4251 /wd4275 /wd4312 /wd4324 /wd4351 /wd4355 /wd4503 /wd4589 /wd4611 /wd4100 /wd4121 /wd4244 /wd4505 /wd4510 /wd4512 /wd4610 /wd4838 /wd4995 /wd4996 /wd4456 /wd4457 /wd4458 /wd4459 /wd4200 /wd4201 /wd4204 /wd4221 /wd4245 /wd4267 /wd4305 /wd4389 /wd4702 /wd4701 /wd4703 /wd4661 /wd4706 /wd4715 /wd4702 -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-user-defined-warnings -Wno-unused-lambda-capture -Wno-null-pointer-arithmetic -Wno-enum-compare-switch -Wno-ignored-pragma-optimize /O1 /Ob2 /Oy- /Zc:inline /Gw /Oi /Z7 -fno-standalone-debug /MT -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang enforce-in-thirdparty-webkit -Xclang -plugin-arg-find-bad-constructs -Xclang check-enum-max-value -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare /wd4267 /TP /wd4577 /GR- /c ../../ui/gfx/font_fallback_win.cc /Foobj/ui/gfx/gfx/font_fallback_win.obj /Fd"obj/ui/gfx/gfx_cc.pdb"In file included from ../../ui/gfx/font_fallback_win.cc:9:In file included from ..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt\wrl.h:18:..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um\wrl\event.h(228,112): error: use of undeclared identifier 'DefaultDelegateCheckMode'

In the file C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um\wrl\event.h

edit lines 228 and 1199 (this is not good, but there is no choice).

On line # 228 instead of:

template<typename TDelegateInterface, typename TCallback, unsigned int argCount, DelegateCheckMode checkMode = DefaultDelegateCheckMode>

specify:

template<typename TDelegateInterface, typename TCallback, unsigned int argCount, DelegateCheckMode checkMode>

On line # 1199 instead of:

extern __declspec(selectany) const DelegateCheckMode DefaultDelegateCheckMode = NoCheck;

specify:

extern __declspec(selectany) const DelegateCheckMode;

— after this remove the current failed chromedriver assembly and recompile again.

If the compilation was successful, then put the updated chromedriver.exe into C:/Windows and first verify that the autotests are still successfully executed in the Chrome — in case of success check the operation in the Sputnik.

I assume that the currently updated Chromedriver will work with any browser on the Chromium engine.


Make your browser supported by Selenium and it will work with all frameworks. Selenium uses browser specific drivers.

Since your browser is based on Chromium, there is a good chance that ChromeDriver will work out of the box.

Documentation how to use Codeception with ChromeDriver.

If you can't make it work, you may need to make some changes in the code so fork chromedriver and amend it to work.

If you had a completely new browser, you would have to implement WebDriver protocol, but I don't think that this is necessary in your case