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?
Related
I started two chrome using
start chrome --remote-debugging-port=9222
start chrome --remote-debugging-port=9223
I tried connecting to these browsers using rpaframework keyword:
RPA.Browser.Selenium.Attach Chrome Browser 9222 alias=site1
RPA.Browser.Selenium.Go To https://google.com
RPA.Browser.Selenium.Attach Chrome Browser 9223 alias=site2
RPA.Browser.Selenium.Go To https://duckduckgo.com
But this is not working, first one is getting connected but the second one is waiting for sometime and then shows error
failed with: WebDriverException: Message: unknown error: cannot
connect to chrome at localhost:9222 from chrome not reachable
Blockquote
You can use Selenium Grid.
Create a Hub:
java -jar sel.jar -role hub -port 9000
Create as many Node you need.
You can run chrome on each node:
java -Dwebdriver.gecko.driver="/driver/geckodriver" -sel.jar -role webdriver -hub http://localhost:9000/grid/register -port 9001
java -Dwebdriver.gecko.driver="/driver/geckodriver" -sel.jar -role webdriver -hub http://localhost:9000/grid/register -port 9002
You can check the nodes using below:
http://localhost:9000/grid/console
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"}
});
I try to remotely debug tests run by Internjs.
Basically it is a Chrome that is run by Selenium and Chromedriver.
I set up Chromedriver debuggerAddress option as
debuggerAddress: '127.0.0.1:8765'
Now when I run tests Selenium waits some time and than fails with message:
FATAL ERROR
UnknownError: [POST http://localhost:4444/wd/hub/session / {"desiredCapabilities":{"browserName":"chrome","name":"tests/intern_local","idle-timeout":60,"selenium-version":"2.44.0","chromeOptions":{"debuggerAddress":"127.0.0.1:8765"}}}] unknown error: cannot connect to chrome at 127.0.0.1:8765
from chrome not reachable
(Driver info: chromedriver=2.12.301326 (093c7e07b4a916b690e784b0374c7f618f1ea4be),platform=Mac OS X 10.10.1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.64 seconds
I'm not sure what I have to do so that chrome would connect to server.
I did try:
Running chromedriver on that port ./chromedriver_2.11 --port=8765
Running chrome with --remote-debugging-port=8765
But I have no other ideas how to start a chrome debug server.
Useful links that I did try that that did not work for me:
Remote debugging protocol
Remotely debugging Chrome Desktop
Chromedriver Capabilities (aka ChromeOptions)
Update 1 Forcing Chromedriver to use a Chrome instance with remote debugging on
Run a new Chrome instance as in Mozilla article
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --no-first-run --no-default-browser-check --user-data-dir=$(mktemp -d -t 'chrome-remote_data_dir')
In intern set
intern.capabilities = {
'selenium-version': '2.44.0'
, 'chromeOptions': {
debuggerAddress: '127.0.0.1:9222'
}
};
Now when you run Intern tests Intern will use your previously open Chrome instance. Now you can open localhost:9222 and you'll see that you can debug that tab in which tests run. However for me I'm just able to see that remote tab, but clicking on it does nothing.
I also tried Firefox WebIDE. I tried to connect to localhost:9222, it starts to load and after some time it says that it can't connect.
I tried something similar this evening, without using a framework. I opened a webdriver session & added the remote debugger capabilities.
It seems that it is not possible to run a webdriver session & remote debug at the same time. I asked some Google guys to verify that, but haven't received an answer yet.
I am trying to use Chrome browser with my Test cases. Same tests work fine with Firefox and PhantomJs.
However , Chrome browser starts but never opens a page.
I have installed
1. Chromdriver : port=9515 version=19.0.1068.0
2. Chrome : Version : 37.0.2062.120 (64-bit)
3. Selenium: Version : 2.42.1
4. RobotFramework : Version : 2.8.5
I think I have Paths variables configured accordingly as well.
google-chrome , starts Chrome
chromedriver , starts chromeDriver
Following line is responsible for starting chrome and opening page.
*** Variables ***
${BROWSER} Chrome
${MY-URL} http://www.google.com/
Open Browser | ${MY-URL} | ${BROWSER}
Errors :
Chrome:
WebDriverException: Message: u'Unable to either launch or connect to Chrome. Please check that ChromeDriver is up-to-date. Using Chrome binary at: /opt/google/chrome/google-chrome'
WebDriver Logs Shows Error
Initializing session with capabilities {
"browserName": "chrome",
"chromeOptions": {
"args": [ ],
"extensions": [ ]
},
"javascriptEnabled": true,
"platform": "ANY",
"version": ""
}
[1.001][INFO]: Launching chrome: /opt/google/chrome/google-chrome --disable-hang-monitor --disable-prompt-on-repost --dom-automation --full-memory-crash-report --no-default-browser-check --no-first-run --ignore-certificate-errors --homepage=about:blank
[46.004][SEVERE]: Failed to initialize connection
<br><br>
Can someone point something I am missing ?
Anyother way of debuging the problem ? Any Clue will be good.
Have you put chromedriver in your PATH ?
And do you run the test with current user or with root ?
Selenium needs chromedriver to call chrome, so you can download it from google.com and put it in /usr/bin, or just update your PATH environment variable.
Then, on Debian, root can't (otherwise with errors) call google-chrome browser, so try it with your account.
Hope it helpful.
NODE,
Please re-check your web driver, delete chrome web driver and download new web driver: Here
Check your VARIABLE NAME again! Do NOT use the "-" character to set a variable name like ${MY-URL}! You should change it => ${MY_URL}
You can try to turn of UAC or/and Firewall and try again.
As i know, when you use selenium2library, you don't need to set path to web driver(!?)
Hope it helpful.
I am launching chrome browser using
selenium = new DefaultSelenium("localhost", 4444, "*googlechrome",
"https://example.com/");
But i get a popup with following message and it freezes:
An administrator has installed Google Chrome on this system, and it is available for all users. The system-level Google Chrome will replace your user-level installation now.
Console Log till point of freeze:
Server started
16:06:37.792 INFO - Command request: getNewBrowserSession[*googlechrome, https://example.com/, ] on session null
16:06:37.796 INFO - creating new remote session
16:06:38.081 INFO - Allocated session beb925cd0418412dbe6319fedfb28614 for https://example.com/, launching...
16:06:38.082 INFO - Launching Google Chrome...
Any suggestions?
Try giving location of your chrome exe too along with browser name like this :
selenium=new DefaultSelenium("localhost", 4444, "*googlechrome C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe", "https://example.com");