Use File System Access API in Chromium Embedded Framework - chromium

My program uses CEF(Chromium Embedded Framework) to implement a simple browser component. I want to use the File System Access API in the CEF to read and write local files but it occurs some problems. https://mburakerman.github.io/file-system-access-api-demo/ is the test page I use to experiment the File System Access API. I used Chrome at first and Chrome behaved well, it read and wrote local files normally. Then I compiled the CEF(The verstion is 96) project and used the cefclient to test whether the CEF also worked well but it could not. CEF could read the local files right but when I clicked the "Save changes" button there was no response and it failed to write the local file I choosed before either. After that I ran the source code of Chromium and CEF to compare the differences in File System Access API. When I was going to write the local file the code of Chromium and CEF ran to the same position as the picture shown below.Chromium and CEF ran to the same position when wrote local files Both of them entered in the DoRequestPermission function. It was very strange that the current_status of Chromium was "ASK" but CEF was "DENIED". The current_status value in CEFThen I checked the stack it showed that the status of the file was initialized at the message dispatch time and I could not find where the status was initialized.The stack of CEF when using File System Access API enter image description hereI wonder why the status in Chromium is "ASK". Does it use some specific command lines or some other methods?

Related

Changing default path for Chrome executable for karate-chrome

I am using the Karate framework to do the API testing. As part of CI efforts, we send an email at the end of test execution listing the summary of test results. There is a need to include the screeshot of the test execution counts from 'overview-feature.html' file.
I did so through the TestRunner.java file - launched Chrome using Chrome.start() and then using it to take screenshot. It all works well locally on Windows.
However when executing on CI server which is a Unix box, the chrome executable is not present in the default location (usr/bin/google-chrome) and hence the connection for the localhost fails.
Is there a way we can change the default location of the chrome executable?
PS: Apologies if this was too trivial to be asked.
Yes Chrome on CI is hard to get right, refer: https://stackoverflow.com/a/62325328/143475 - note that CI boxes typically are "headless" a browser may not be even installed.
I think the best thing for you is to ZIP the HTML and send it. But I really think you need to work with some CI experts, because the report generation and e-mailing business is normally done by things like Jenkins. What you are doing is certainly not normal or best-practice.
If you really want, there is a Karate Docker container that can give you a proper Chrome instance (see docs) but that is overkill for what you need.
EDIT: The Chrome Java API allows for customization of the executable path and this is in the docs: https://github.com/intuit/karate/tree/master/karate-core#chrome-java-api
It should be something like this:
Chrome.start("/opt/blah/chrome");

Selenium Tests for Internet Explorer doesn't executs properly through Jenkins

We have our Health Check automated wherein all of our applications are logged onto, all via Selenium and only on Internet Explorer.
The code runs well when it was executed directly from a batch file. However, when Jenkins calls this batch (.bat) file, it doesn't execute it completely.
BTW the platform is Windows Server 2008 R2 Standard
This is the .bat file code
#echo off
set path="";
set path="E:\XXXX\jre1.8.0_141\bin";
pushd E:\Jenkins_Softwares\SeleniumCode\HealthCheck_jar
SET JAVA_OPTS=-Xmx4g -Xms512m -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=128m -XX:MaxHeapSize=512m
java -jar HealthCheck_JenkinsNG.jar
I've added these additional IE options in the JAVA code before launching the IE driver.
InternetExplorerOptions options = new InternetExplorerOptions();
options.introduceFlakinessByIgnoringSecurityDomains();
options.enableNativeEvents();
options.destructivelyEnsureCleanSession();
When Jenkins executes the batch file, the IE browser opens into the Login page. There's something odd when this page is displayed - the entire page alignment is disrupted and all elements get aligned to the left. (I'd like to stress that when the batch file is instead executed directly, there is no such page alignment disruption. The elements retain their original centre position. For some reason, Jenkins sets all of this to the left). The alignment is not exactly a deal breaker for me.
However, when username and password is entered via the Selenium code, it types into the perfect text boxes; but when the submit button is hit, the content in these textboxes turn blank and I'm unable to login. (When this same piece of code is executed via running the batch file directly, I'm able to login and The homepage of my application is displayed)
I doubt if there's something wrong with the selenium java code. Since, it executes properly, when run from the .bat file or even command line or even as a Java Application from an IDE.
For some reason, when this is executed from Jenkins it does not work.
Is there any options or settings that needs to be set when Jenkins works with Selenium on IE 11? Because I've tried tweaking the selenium code so much, they all yield the same result - The elements on the Login page get cleared after the submit button is clicked.
Also, just to mention, all of this is run on one Master node of Jenkins only. There are no slave nodes.
You need to take care of a couple of things as follows:
For the build process Jenkins would need the path of jdk. Simply jre may not suffice.
JDK 8u141 is ancient now and you need to upgrade to latest JDK 8u202
introduceFlakinessByIgnoringSecurityDomains() (in Java) and IntroduceInstabilityByIgnoringProtectedModeSettings() (in DotNet) is not an ideal solution to address the issues croping out of Protected Mode settings.
Here you can find a detailed discussion in Internet Explorer Protective mode setting and Zoom levels
To work with Selenium, InternetExplorerDriver and InternetExplorer you need to fulfill the Required Configuration

CEF 3 Disable WebRTC - Ip leaks

Can we disable WebRTC in CEF 3 ?
I`m referring specifically to JavaScript access to local ips.
Chrome seems to have settings like chrome.privacy.network.webRTCMultipleRoutesEnabled that help - but these do not seem to exist in CEF.
I had same problem and ended up rebuilding CEF and Chrome without WebRTC support. Here is steps, which I use:
Download automate-git.py script in c:/code/automate folder from here: https://bitbucket.org/chromiumembedded/cef/raw/master/tools/automate/automate-git.py
Create batch with following content and run it:
SET GYP_MSVS_VERSION=2015
python c:/code/automate/automate-git.py --verbose-build --download-dir=C:/code/chromium_git --branch=[REPLACE WITH CURRENT BRANCH] --minimal-distrib --no-debug-build --force-build
pause
Set enable_webrtc to 0 inside C:\code\chromium_git\chromium\src\build\common.gypi file.
Run batch again.
And maybe there there is easier way, for example, using CefRequestContext::SetPreference.

Static html pages run from file system instead of built-in web-server

I'm running Intellij 13 Ultimate. I'm trying to open a web page I'm working on, and it's opened from the file system:
file:///Users/<username>/dev/index.html
Instead of something like:
http://localhost:<port>/index.html
Thing is, other projects run as expected and I can't figure out what's misconfigured in this specific project.
How do you open the page?
If you open your HTML file inside IntelliJ and go to Run > Run xxx.html (or Debug), a localhost page should be opened. If it isn't, check your Run Configuration (Run > Edit Configurations) and check the URL field.
View > Open in Browser should also work as expected.

Waiting for file to download on selenium grid

I have a test using Webdriver and C# which downloads a file from a website.
When running this test on my local machine it works fine but when I try to run it on Selenium grid it Looks for the file I'm downloading on the hub and not on the node.
Is the anyway of accessing the node file structure to monitor when the file is downloaded.
Sorry if this is unclear.
Thanks
Aidan
It seems, there is no such possibility.. I have also tried to find such functionality, but failed.
But, one way to check it still exists - "upload downloaded". Of course it is workaround and not always you have such function as upload.
Anyway, you may:
download test data
delete test data from page
upload test data on page again
check it was really appeared
It is quite dirty way, but on other hand it allows you to test not only download function, but also upload function.