How to add HTML5 support to Chromium? - html5-video

I would like to know how to add HTML5 video support into a chromium build, by default chromium dose not play them.

Chromium, by default doesn't support playing those file formats. You will have to add support for those codecs when compiling Chromium. Chromium uses Ninja build system, you should pass the below arguments or use this command
gn args out/YourBuildFolder
to open args.gn file in a text editor and paste and save it:
ffmpeg_branding = "Chrome"
proprietary_codecs = true
before compiling Chromium. Now compile your Chromium fork:
ninja -C out/YourBuildFolder chrome

Related

Electron cannot access user data directory when using Selenium ChromeDriver

I am using Selenium with Robot Framework to run an Electron application. The application is built to read a configuration file from the user data directory. As far as I understand, this is the location where this file should be stored.
The electron main process reads the configuration file:
const localConfigFile = path.join(app.getPath('userData'), 'config.json');
const localConfig = fs.existsSync(localConfigFile) ? require(localConfigFile) : {};
The built production version works just fine and reads the file as expected, but when starting it from Robot using SeleniumLibrary, the file is not read. This leads me to believe it's a problem with Robot, Selenium or ChromeDriver.
Robot creates the webdriver using SeleniumLibrary:
Create Webdriver Remote desired_capabilities=${starting_parameters} command_executor=http://127.0.0.1:9515
Where starting parameters are simply:
{ "chromeOptions": {"binary": <binary_location> }}
Chromedriver is started as a separate process from /usr/bin/chromedriver where it has been installed and uses the default port 9515.
The versions that I am using are:
ChromeDriver 2.36.540471 (9c759b81a907e70363c6312294d30b6ccccc2752)
"electron": "^6.0.2"
"electron-builder": "^21.2.0"
robotframework==3.2.1
robotframework-seleniumlibrary==3.3.1
Ubuntu 18.04.4 LTS
Experienced the same problem. Finally changing the Chromedriver's user-data-dir argument to Electron's userDataDir solved the problem.
options.add_argument('--user-data-dir=' + str(app_config_path()))
I found out the problem by using Spectron and logging the Electron main console. In general I would advice using Spectron instead of Robot to test Electron apps.
The issue is that the user data directory was not the same as the Electron default. When running the application through Chromedriver, the user data directory is changed to /tmp/somethingsomething so naturally the file under ~/.config/app-name was not found.
My solution was to use Electron'ss application data directory instead:
app.getPath('appData')
By default this is one directory up from the user data directory, but remains the same when running through Chromedriver.

Unable to download a file when chromedriver is in headless mode. How to get it work?

During the test, a file (.html) will be downloaded from the web application & I have to verify that file by opening it on the browser. In the non-headless mode, my test is working fine. But whenever I'm going to headless mode, that file is not getting downloaded to the download path (i.e. pointed in the "user.dir"). My chrome driver version is 2.44.609538 & selenium version is 3.14.
Apparently this could help you
Shawn Button post the answer related with it.
Downloading with chrome headless and selenium
Are you running the test from the command line?
Because, according to an answer to this question and this, when you run it via command line, your user.dir corresponds to your global user directory (C:\users\username).
This worked for our ruby implementation:
Capybara.register_driver :scrapping_driver do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')
options.add_argument('--disable-popup-blocking')
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--window-size=1366,2000')
options.add_preference(:download, directory_upgrade: true,
prompt_for_download: false,
default_directory: "#{Rails.root}/")
options.add_preference(:browser, set_download_behavior: { behavior: 'allow' })
Selenium::WebDriver::Service.driver_path = Webdrivers::Chromedriver.driver_path
driver = Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end
Pay attention at download behaviour
I met same situation.
Headless mode is very faster. So your code might be implemented to detect download(DL).
Solution.
(Current your process?) .click for DL -> Detecting download file generation.
(My solution) Detecting download file generation -> .click for DL.
I implemented the above mechanism using callback function.

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

What is required to add a browser to the list of available browsers for UI-automation frameworks/wrappers to successfully running of autotests through the appropriate browser? For example, I want to adding browser "Sputnik", which using Chromium core.
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 chromium
d:\chromium> mkdir src
d:\chromium> cd src
d:\chromium\src> gclient sync
d:\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 directory
ninja: 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.obj
FAILED: 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

Run js-test-driver Eclipse plugin in IE8 document mode when having IE9 installed

I want to use the Eclipse plugin of js test driver to execute my tests in IE. I have IE9 installed but want the tests to run in IE8 document mode because this is what the app we are developing is running in.
So is there any way to start the js-test-driver plugin in IE8 document mode when having IE9 installed? Its possible to switch mode in MS Developer Tools but that is not what I'm looking for.
I've tried to load a script that adds meta tags at start up by adding a script like this in the jsTestDriver.conf file:
...
load:
- js/bootstrap-IE8.js
...
and the code in the bootstrap file:
(function(){
var meta = document.createElement('meta');
meta.setAttribute('http-equiv','X-UA-Compatible');
meta.setAttribute('content','IE=8');
var meta2 = document.createElement('meta');
meta2.setAttribute('Content-Type','X-UA-Compatible');
meta2.setAttribute('content','text/html; charset=utf-8');
var tophead = top.document.getElementsByTagName('head')[0];
var toptitle = tophead.firstChild;
tophead.insertBefore(meta, toptitle);
tophead.insertBefore(meta2, toptitle);
})();
I have tried to find a way to solve this as you describe have not found any way to do this (or JSTestDriver files to modify)
However, this can be done by modifing the registry by setting FEATURE_BROWSER_EMULATION feature that defines the default emulation mode for Internet Explorer to 8888 (0x22B8).
It is descibed at http://msdn.microsoft.com/en-us/library/ee330730%28VS.85%29.aspx#browser_emulation
Note that your browser will use IE8 document mode always.

Can't get PhantomJS to work with a simple example

I've downloaded the executable and created a simlink to /usr/local/bin.
I'm under Mac OSX 10.7
When I then try to run a script that requires some module i.e.
var page = require('webpage').create();
I got an error
undefined:0 ReferenceError: Can't find variable: require
as if 'require' is not seen as a reserved word but interpreted as a variable symbol.
(As an aside, whenever I lunch phantomjs a Sencha Touch icon appears in my Dock)
Your copy of PhantomJS is from an older version. Always get the latest one from http://phantomjs.org.
I had this issue too, and the problem was my version of mocha -- going back to 1.9.0 fixed it.
SenchaTouch 2.0 installs PhantomJS 1.1 somewhere depending on the OS. Under *NIX check where with 'which phantomjs'.
Just modify your bash or whatever configuration file accordingly to remove the Phantomjs included with SenshaTouch from your PATH.