The error started to happen after updating google chrome to the latest version: 89.0.4389.82 (Official Build) (64-bit).
OS: Windows 10
Error:
PuppeteerSharp.ChromiumProcessException:
Failed to launch Chromium! [0309/160320.924:ERROR:os_crypt_win.cc(70)] Failed to encrypt: The system cannot find the file specified. (0x2)
Help, please!
I too got the same error while launching the chrome in the server using an application. I did upgrade google chrome manually and everything worked fine as normal.
after much faffing around trying to get this working in an asp.net app running in a production server environment (windows server 2019 in azure VM), i wanted to elaborate on vidya's answer "upgrade google chrome manually":
set the version number manually based on the latest version on this URL:
https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win_x64/
in my case that version is 890410. set your code to use this version instead of DefaultChromiumRevision
const string ChromiumRevision = "890410";
var options = new BrowserFetcherOptions();
options.Path = HttpContext.Current.Server.MapPath("/App_Data");
var bf = new BrowserFetcher(options);
await bf.DownloadAsync(ChromiumRevision);
string exePath = bf.GetExecutablePath(ChromiumRevision);
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Headless = true,
ExecutablePath = exePath,
Args = new string[]{"--disable-gpu","--no-sandbox"}
});
Related
I am developing web crawler which could render Javascript websites and so I decided to use PupeeteerSharp, a .NET port of popular Node.JS headless Chrome browser Pupeeteer API. I am running Service Fabric's local development cluster on Windows 10 development machine and have one stateless service in my solution.
I've created Data folder under Service project's PackageRoot folder and put .local-chromium folder contents there (contains chrome.exe executable) so it deploys as independent data package of service.
I've also placed this XML config line in ServiceManifest.xml file:
<DataPackage Name="Data" Version="1.0.0" />
So far it looks good and headless browser content is copied to SFCluster Data package directory properly.
Then in my Stateless Service code I try to call Pupeeteer chromium executable as follows:
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Headless = true,
ExecutablePath = _chromiumPath // #$"{context.CodePackageActivationContext.GetDataPackageObject("Data").Path}\.local-chromium\Win64-706915\chrome-win\chrome.exe"
});
using (var page = (await browser.NewPageAsync()))
{
Response renderResponse;
try
{
renderResponse = await page.GoToAsync(webPage.AbsoluteUri, timeout);
if (renderResponse.Status != System.Net.HttpStatusCode.OK)
{
return new RenderResult(RenderStatus.OtherFailure);
}
// other code
}
catch (TimeoutException)
{
return new RenderResult(RenderStatus.Timeouted);
}
In this line: using (var page = (await browser.NewPageAsync())) my code (Thread) simply hangs without returning, in Debug console I see many thread exits, but no exception occurs. I was previously getting System.IO.FileNotFoundException when I was fixing some other errors regarding appropriate copying of chromium folder contents, but now these errors are gone so it seems that code find .exe but somehow cannot start headless mode of PupeeterSharp.
Does that mean that I cannot simply run external .exe chromium binary with Service Fabric's Native Application Model? Should I use Docker and Linux containers instead?
I have updated version of chrome as well as WebDriver. Still getting the timeout exception. It was working properly previously but suddenly it started giving exception. It is not even reaching to test as well. If anyone has solution lease help.
Version 64.0.3282.140 (Official Build) (64-bit)
Webdriver: WebDriver.ChromeDriver.win32 2.35.0
var smth = m_driver.WaitUrl(new Regex(settings.GetSiteString("xyz") + "#/.*"));
for (int maxWait = 60000; maxWait > 0; maxWait--, System.Threading.Thread.Sleep(500))
if (m_driver.FindElement("//div[#ng-show='vm.loaded']").Displayed)
{
System.Threading.Thread.Sleep(500);
return;
}
throw new TimeoutException("Failed to wait for xyz page to load.");
Error message: The HTTP request to the remote WebDriver server for URL http://localhost:63425/session/cdc3e59/url timed out after 120 seconds.
It seems that adding the no-sandbox argument to your chrome driver options fixes the problem. I'm still trying to figure out why this fixes it.
Here is an example of how to instantiate a ChromeDriver so that it doesn't give you timeouts on pages that actually load properly.
var chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("no-sandbox");
var webDriver = new ChromeDriver(Directory.GetCurrentDirectory(), chromeOptions);
I found this solution in this Github thread
I have a simple F# project which use Selenium and Chrome. I noticed that when Chrome is launched in headless mode the chrome object is not defined.
On the other side, if I run it "normally" the chrome object is correctly referenced.
Sample code:
let chromeOptions = new ChromeOptions(BinaryLocation = _chrome)
chromeOptions.AddArguments
(
"--headless",
"--disable-gpu"
)
let chrome = new ChromeDriver(chromeOptions, Url = "http://www.example.com")
try
Console.WriteLine(chrome.Capabilities.Platform)
Console.WriteLine(chrome.Capabilities.BrowserName)
Console.WriteLine(chrome.Capabilities.Version)
let res = chrome.ExecuteScript("return chrome;")
Console.WriteLine(res)
with e ->
Console.WriteLine(e.Message)
chrome.Quit()
If I run the code above I got the following output:
Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 61158
Only local connections are allowed.
Any
chrome
62.0.3188.0
unknown error: chrome is not defined
(Session info: headless chrome=62.0.3188.0)
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 10.0.15063 x86_64)
If I omit the headless option I got the following output:
Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 60248
Only local connections are allowed.
Any
chrome
62.0.3188.0
System.Collections.Generic.Dictionary`2[System.String,System.Object]
Is this a bug or I am missing something?
I am currently running awebapp with an embedded neo4j. Now I want to change to a standalone neo4j server using bolt. Neo4j has been loaded onto a standalone and port 7474 work as expected.
Using the following code works as expected:
var authority = neo4j.v1.auth.basic("neo4j", "XXXXXXXX");
_driver = neo4j.v1.driver("bolt://localhost ", authority, {encrypted:false});
However
var authority = neo4j.v1.auth.basic("neo4j", "XXXXXXXX");
_driver = neo4j.v1.driver("bolt://somesite.com/ ", authority, {encrypted:false});
Fails with:
neo4j-web.js:27568 WebSocket connection to 'ws://somesite.com:7687/' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET
The port 7687 has been enabled. The neo4j version 3.0.4 and the server operating system is Centos 7.
What am I missing?
Thanks for the help
you need to enable remote connections by adding the following line to conf/neo4j.conf:
dbms.connector.bolt.address=0.0.0.0:7687
Stefan's answer works for Neo4j 3.0 (see this KB article).
For those that are having an issue like Maulik, you are probably using a more recent version of Neo4j (3.5, 4.x), in which case you need to use the following instead:
dbms.connector.bolt.advertised_address=localhost:7687
dbms.connector.bolt.listen_address=0.0.0.0:7687
I have a problem with the Selenium web driver. What I'm trying to do is to start a "portable" chrome instead of my local installation, because it has different settings.
The problem is that the portable Chrome (from PortableApps) seems to only start when using GoogleChromePortable.exe. If I use the Chrome binary directly, it will start my local installation.
With Selenium it seems that no matter what Chrome path I pass to it (GoogleChromePortable.exe or binary path), it starts my local installation.
Here is my code:
String chromePath = "M:/my/path";
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
capabilities.setCapability("chrome.binary", chromePath);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
Any ideas how to be able to start my portable chrome?
Thanks
For anyone else stumbling upon this problem, here is how I managed to get the portable Chrome starting:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary(binaryPath);
driver = new ChromeDriver(chromeOptions);
I'm using Python 3.7 on Windows 10 and got Chrome Portable from PortableApps.com.
comments by #mario.schlipf and #SeJaPy were helpful, but I noticed that in the newer Webdriver releases, the setbinary method has been replaced by binary_location
This is how it actually worked for me:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chromedriverpath='M:/my/chromedriver.exe'
chromePath = 'M:/my/App/Chrome-bin/chrome.exe' # <== IMPORTANT! See note below.
chromeoptions = Options()
chromeoptions.add_argument('--incognito')
chromeoptions.binary_location = chromePath
browser = webdriver.Chrome(executable_path=chromedriverpath, options=chromeoptions)
NOTE:
The chromePath variable must point to the Chrome executable in the portabilized environment.
In packages obtained from PortableApps.com, you have two executables: a GoogleChromePortable.exe in the install (actually, unpack) directory and a chrome.exe in [installdirectory]/App/Chrome-bin, the first being "just" a launcher which provides the portabilized app with a consistent environment.
As I could observe, chromedriver needs to directly interact with the "real" Chrome executable, otherwise the script will launch the browser (via the launcher) but will eventually crash with error message:
unknown error: DevTools Active Port file doesn't exist
and no browser session will be returned as a result.
This may seem obvious to many people... but it was not to me, so I decided to put this note in order to make some clarity for the less clever guys (myself included) :).
String chromePath = "M:/my/googlechromeporatble.exe path";
String chromedriverpath="M:/my/chromedriver.exe path";
ChromeOptions options = new ChromeOptions();
options.setBinary(chromepath);
System.setProperty("webdriver.chrome.driver",chromedriverpath);
driver = new ChromeDriver(options);
This will invoke portable chrome rather than local installation.
First set google chrome portable path and then invoke chromeriver.exe
Depending on the settings you have in ChromePortable, maybe you could default ChromeDriver with Capabilities & ChromeOptions?
I'm thinking especially on custom profile. If you somehow could get that from your ChromePortable and load it with default ChromeDriver?
EDIT: Maybe this could help