When I run a .robot file that uses the browser library the test fails with this error in the logs
Calling method '_start_suite' of listener 'Browser' failed: Could not connect to the playwright process at port 52161
(I have already installed playwright with this command "npx playwright install" and run "rfbrowser init")
I found out that I need to install a node version> 12 so I installed the version 16.13.0
I run again "rfbrowser int"
When I execute the .robot file the test fails with this error
TimeoutError: browserType.launch: Timeout 30000ms exceeded.
/mnt/c/Users/skhalil/workspace2/rf_training/ve_rftr/lib/python3.8/site-packages/Browser/wrapper/node_modules/playwright-core/.local-browsers/chromium-930007/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-Y7xOid --remote-debugging-pipe --no-startup-window
pid=5743
[pid=5743][err] [5743:5743:1128/225155.804904:FATAL:ozone_platform_x11.cc(238)] Check failed: x11::Connection::Get()->Ready(). Missing X server or $DISPL...
[ Message content over the limit has been removed. ]
..ch-11" = "--disable-features=ImprovedCookieControls,LazyFrameLoading,Globa"
[pid=5743][err] "switch-10" = "--disable-extensions"
[pid=5743][err] "switch-9" = "--disable-dev-shm-usage"
[pid=5743][err] "switch-8" = "--disable-default-apps"
[pid=5743][err] "switch-7" = "--disable-component-extensions-with-background-pages"
[pid=5743][err] "switch-6" = "--disable-client-side-phishing-detection"
[pid=5743][err] "switch-5" = "--disable-breakpad"
[pid=5743][err] "switch-4" = "--disable-backgrounding-occluded-windows"
[pid=5743][err] "switch-3" = "--disable-background-timer-throttling"
[pid=5743][err] "switch-2" = "--enable-features=NetworkService,NetworkServiceInProcess"
[pid=5743][err] "switch-1" = "--disable-background-networking"
[pid=5743][err] "num-switches" = "30"
[pid=5743][err] "osarch" = "x86_64"
[pid=5743][err] "pid" = "5743"
[pid=5743][err] "ptype" = "browser"
[pid=5743][err]
[pid=5743][err] [1128/225218.444392:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu
Regarding the first error you stated:
Calling method '_start_suite' of listener 'Browser' failed: Could not connect to the playwright process at port
I get this when I have the environmental variables https_proxy and/or http_proxy (case insensitive) set. Just unset them and it should work. (I always set those vars only temporarily for my session when I need to install new packages behind company proxy)
Regarding the second error:
TimeoutError: browserType.launch:...
In my company we started to get this suddenly a few months back, we could not find the cause for it and it affected windows users only, on mac it still worked (no linux users among us tho). The chrome.exe from the browser lib just could not be opened any more, not even manually - there is no error it just simply won't launch. Firefox would still work, however. Since we use chromium baseds browser in our company, we did not want firefox thus we solved this by setting the 'channel' arg to use installed stock browser rather then the one from Browser lib like this:
Suite Setup New Browser channel=chrome
...or channel=edge if you prefer.
Related
I'm trying to setup tests with NodeJS, Selenium & Jest. They work fine on my Mac but both a Windows and Linux install are failing with similar errors:
WITHOUT THE PATH EXPLICITLY SET
WebDriverError: unknown error: cannot find Chrome binary
at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:522:15)
at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:548:13)
at Executor.execute (node_modules/selenium-webdriver/lib/http.js:474:28)
WITH THE PATH EXPLICITLY SET
WebDriverError: unknown error: Chrome failed to start: exited
abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/local/bin/chromedriver is no longer running, so ChromeDriver is
assuming that Chrome has crashed.)
FWIW on a linux machine running chromedriver directly I get this:
Starting ChromeDriver 98.0.4758.80
(7f0488e8ba0d8e019187c6325a16c29d9b7f4989-refs/branch-heads/4758#{#972})
on port 9515 Only local connections are allowed. Please see
https://chromedriver.chromium.org/security-considerations for
suggestions on keeping ChromeDriver safe. ChromeDriver was started
successfully.
Setting the path directly has not worked, using a globally installed (/usr/local/bin/chromedriver) binary and a local one node_modules/chromedriver/bin/chromedriver). None of the following options has made any difference:
.addArguments([
"--ignore-certificate-errors",
"--disable-extensions",
"--disable-popup-blocking",
"--enable-automation",
"--disable-dev-shm-usage",
"--no-sandbox",
"--headless",
"--log-path=/home/jsp/projects/proj/selenium/chrome.log",
"--append-log",
"--verbose",
"--enable-chrome-logs",
"--port=9222"
])
Enabling logging generated an empty chrome.log file. I tried simplifying and this is what I ended up with that again works on my Mac but not on the Linux test box.
const { Builder } = require("selenium-webdriver");
const chrome = require("selenium-webdriver/chrome");
let chromeTest = async () => {
let options = new chrome.Options()
.setChromeBinaryPath('/usr/local/bin/chromedriver')
.addArguments(["headless", "ignore-certificate-errors", "disable-dev-shm-usage", "no-sandbox"]);
let driver = await new Builder()
.forBrowser("chrome")
.setChromeOptions(options)
.build();
await driver.quit();
};
chromeTest();
Selenium: 4.1.1
ChromeDriver: 98.0.4758.80
Ubuntu 20.04.3
Any help would be greatly appreciated.
I want to run protractor tests on a webserver integration platform without gui based on redhat linux. The tests will be executed whenever the webserver software will be deployed. I use firefox and geckodriver.
The call chain is
protractor calls
firefox on
Xvfb calls
(local) Webserver
and backwards to the caller.
I get Jasmine timeouts when starting Protractor with Xvfb.
My environment:
node: v12.14.1
npm: 6.14.2
Xvfb: ?, installed, callable
xvfb-run: ?, installed, callable
My start scripts:
Selenium:
java -jar -Dwebdriver.chrome.driver=/pathx/geckodriver-v0.26.0 /pathy/selenium-server-standalone-3.141.59.jar &
This is essentially what 'webdriver-manager start' does, but I cannot need the update ahead.
Xvfb:
xvfb-run --auto-servernum --server-args='-screen 0 1920x1200x24' -e xvfb.err firefox &
Protractor:
DISPLAY=:99 protractor --verbose --troubleshoot --logLevel=DEBUG protractor.conf.js
All I get is
[15:00:59] D/launcher - Running with --troubleshoot
[15:00:59] D/launcher - Protractor version: 5.4.3
[15:00:59] D/launcher - Your base url for tests is undefined
[15:00:59] I/launcher - Running 1 instances of WebDriver
[15:00:59] I/direct - Using FirefoxDriver directly...
[15:01:00] D/runner - WebDriver session successfully started with capabilities C apabilities {
map_: Map {
'acceptInsecureCerts' => false,
'browserName' => 'firefox',
'browserVersion' => '60.9.0',
'moz:accessibilityChecks' => false,
'moz:geckodriverVersion' => '0.26.0',
'moz:headless' => false,
'moz:processID' => 32246,
'moz:profile' => '/tmp/rust_mozprofileAz14ww',
'moz:useNonSpecCompliantPointerOrigin' => false,
'moz:webdriverClick' => true,
'pageLoadStrategy' => 'normal',
'platformName' => 'linux',
'platformVersion' => '3.10.0-957.el7.x86_64',
'rotatable' => false,
'timeouts' => { implicit: 0, pageLoad: 300000, script: 30000 }
}
}
[15:01:00] D/runner - Running with spec files /home/xgadvls/az-uss/frontend/e2e/ src/specs/login/login-spec.ts,/home/xgadvls/az-uss/frontend/e2e/src/specs/logout /logout-spec.ts
Started
undefined
F(node:32231) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
FA Jasmine spec timed out. Resetting the WebDriver Control Flow.
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
FA Jasmine spec timed out. Resetting the WebDriver Control Flow.
Failures:
1) Anmeldung Anmeldedate werden eingegeben
Message:
Failed: WebDriverError
Stack:
Error: Failed: WebDriverError
at /home/xgadvls/az-uss/node_modules/jasminewd2/index.js:64:48
...
How can I get a webdriver error when I haven't got it in my call chain?! What am I doing wrong? Can anybody help?
The problem was caused by an invalid certificate.
My way to the solution may be interesting.
I renamed the geckodriver-v0.26.0 (or so) to geckodriver.bin.
I made a script with the original geckodriver name and called in that script the bin version with -vv argument (very verbose) and redirected the output into a file (>myfile). It is important to pass all parameters ($#).
The next test informed me in the log file about the invalid certificate. This can be fixed by a parameter AcceptInsecureCerts for firefox. (I guess chrome as well)
Here we go.
I hope this helps anybody.
I just installed selenium-side-runner on Mac Mojave and am trying to run a test from the command line using a test I recorded in the IDE. My test file name is "myTest.side". I created a "myTest.side.yml" file to tell selenium-side-runner where my drivers are ...
capabilities:
chromeOptions:
binary: '/Users/davea/Documents/workspace/starter_project/selenium/chromedriver_mac'
firefoxOptions:
binary: '/Users/davea/Documents/workspace/starter_project/selenium/geckodriver_mac'
However, when I try and run my tests, I'm getting this error ...
localhost:selenium davea$ selenium-side-runner -c "browserName=firefox" myTest.side
info: Running myTest.side
FAIL ./DefaultSuite.test.js
● Test suite failed to run
The geckodriver executable could not be found on the current PATH. Please download the latest version from https://github.com/mozilla/geckodriver/releases/ and ensure it can be found on your PATH.
at findGeckoDriver (../../../../../../../usr/local/lib/node_modules/selenium-side-runner/node_modules/selenium-webdriver/firefox.js:444:11)
at new ServiceBuilder (../../../../../../../usr/local/lib/node_modules/selenium-side-runner/node_modules/selenium-webdriver/firefox.js:533:22)
at Function.createSession (../../../../../../../usr/local/lib/node_modules/selenium-side-runner/node_modules/selenium-webdriver/firefox.js:591:21)
at createDriver (../../../../../../../usr/local/lib/node_modules/selenium-side-runner/node_modules/selenium-webdriver/index.js:155:33)
at Builder.build (../../../../../../../usr/local/lib/node_modules/selenium-side-runner/node_modules/selenium-webdriver/index.js:670:16)
at buildDriver (../../../../../../../usr/local/lib/node_modules/selenium-side-runner/node_modules/jest-environment-selenium/dist/index.js:66:17)
at WebdriverEnvironment.setup (../../../../../../../usr/local/lib/node_modules/selenium-side-runner/node_modules/jest-environment-selenium/dist/index.js:37:32)
Test Suites: 1 failed, 1 total
How do I run my test from the command line using Firefox?
As commented earlier, the reason your code doesn't work is the file naming convention.
By default the selenium-side-runner will pick the file .side.yml and not <somename>.side.yml
So if you just rename the file, it should pickup the correct details for you
Update: 16th July
After lots of hours of debugging, it seems what you are experiencing is a bug. So what happens is quite visible in the error
at new ServiceBuilder (selenium-webdriver/chrome.js:232:13)
at getDefaultService (selenium-webdriver/chrome.js:321:22)
at Function.createSession (selenium-webdriver/chrome.js:694:44)
at createDriver (selenium-webdriver/index.js:155:33)
at Builder.build (selenium-webdriver/index.js:662:16)
at buildDriver (jest-environment-selenium/dist/index.js:73:17)
at WebdriverEnvironment.setup (jest-environment-selenium/dist/index.js:39:32)
selenium-side-runner use jest-environment-selenium package and calls the setup method with below code
async setup() {
await super.setup();
this.global.driver = await buildDriver(this.configuration);
}
Now this configuration is being passed using jest and is there in the package.json of the test files generated on the fly
As you can see the configuration is passed. Now if we look at the jest-environment-selenium and the buildDriver function
async function buildDriver(configuration) {
const driver = new _seleniumWebdriver2.default.Builder().withCapabilities(configuration.capabilities);
if (configuration.server) driver.usingServer(configuration.server);
if (configuration.proxyType) {
let prxy;
if (configuration.proxyType === 'socks') {
prxy = _proxy2.default.socks(configuration.proxyOptions.socksProxy, configuration.proxyOptions.socksVersion);
} else {
prxy = _proxy2.default[configuration.proxyType](configuration.proxyOptions);
}
driver.setProxy(prxy);
}
return driver.build();
}
The driver does get initiated with withCapabilities(configuration.capabilities) and the capabilites do have the driver path also, but it seems webdriver will do nothing of these options. The initiator needs do all the work
If I update the function like below
async function buildDriver(configuration) {
const driver = new _seleniumWebdriver2.default.Builder().withCapabilities(configuration.capabilities);
if (configuration.server) driver.usingServer(configuration.server);
if (configuration.proxyType) {
let prxy;
if (configuration.proxyType === 'socks') {
prxy = _proxy2.default.socks(configuration.proxyOptions.socksProxy, configuration.proxyOptions.socksVersion);
} else {
prxy = _proxy2.default[configuration.proxyType](configuration.proxyOptions);
}
driver.setProxy(prxy);
}
if (configuration.capabilities && configuration.capabilities.chromeOptions) {
var options = new _chrome.Options()
var service = new _chrome.ServiceBuilder(configuration.capabilities.chromeOptions.binary || null)
driver.setChromeService(service)
}
return driver.build();
}
And now the test starts working. The repo for jest-environment-selenium is available on below
https://github.com/applitools/jest-environment-selenium
You can report and discuss the issue. In the meantime can workaround the issue by running the command like below
$ PATH=/Users/davea/Documents/workspace/starter_project/selenium/:$PATH selenium-side-runner -c "browserName=firefox" myTest.side
Create a .side.yml file in the directory you'll be running your tests from. The runner will pick it up automatically. Here is an example of the file's contents. As is from Selenium Command-Line Runner.
So please make sure to change the name of the file.
Or you can use --config-file without changing the name of your file. --config-file will ignore the .side.yml and picks up the configuration from the specified path.
selenium-side-runner --config-file "/path/to/your/config.yaml"
Credit Goes of Selenium IDE Documenation
I'm setting up CI for our project that is in Angular. We are using Google Cloud Platform's Cloud Builder for CI. Everything is going smoothly, we can setup the environment, install packages via npm, build the project using angular-cli and deploy. But the problem is that our test cases (e2e) in Protractor keeps getting an error. What are we missing here?
This is for the Continuous Integration using Google Cloud Builders, we are running the protractor in headless mode, and using the puppeteer's chromium as the chrome's binary path
This is my protractor.conf.js
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath()
exports.config = {
allScriptsTimeout: 1000000,
specs: [
'./e2e/*.e2e-spec.ts',
'../e2e/*.e2e-spec.ts'
],
capabilities: {
// browserName: 'chrome',
browserName: 'chrome',
chromeOptions: {
binary: process.env.CHROME_BIN,
args: ['--headless', '--disable-gpu', '--no-sandbox', '--disable-extensions', '--disable-dev-shm-usage', '--disable-setuid-sandbox']
}
},
// seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
// ignoreUncaughtExceptions: true,
directConnect: true,
},
};
This is the error we are getting in cloud builders
[11:24:12] E/launcher - unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-1033-gcp x86_64)
[11:24:12] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
After upgrading to chromedriver 74 noticed odd extensions behaviour on Windows.
Is it possible to switch ALL extensions off?
Start chromedriver
chromedriver --log-level=ALL
Create session with extensions DISABLED
curl -d '{"desiredCapabilities":{"browserName":"chrome","goog:chromeOptions":{"args":["--disable-extensions"]}}}' http://localhost:9515/session
Some dev tool extension is loaded
[1558606783.990][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-extensions --disable-extensions-except="C:\Users\user\AppData\Local\Temp\scoped_dir19964_411\internal" --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --force-fieldtrials=SiteIsolationExtensions/Control --ignore-certificate-errors --log-level=0 --no-first-run --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\user\AppData\Local\Temp\scoped_dir19964_22650" data:,
Note
--disable-extensions-except="C:\Users\user\AppData\Local\Temp\scoped_dir19964_411\internal"
Is there a way to get rid of it? Did not find any clues in chromedriver docs, those are extremely sketchy.
TL;DR
Set chromeOptions.useAutomationExtension to false, it will prevent injecting of Chrome Automation Extension
{
"desiredCapabilities": {
"browserName": "chrome",
"goog:chromeOptions": {
"useAutomationExtension": false,
"args": [
"--disable-extensions"
]
}
}
}
Long version
Automation Extension flag is not mentioned in chromedriver docs http://chromedriver.chromium.org/capabilities, but can be traced in source code for current version (75.0.)
parser_map["useAutomationExtension"] =
base::Bind(&ParseBoolean, &capabilities->use_automation_extension);
status = internal::ProcessExtensions(
capabilities.extensions, extension_dir->GetPath(),
capabilities.use_automation_extension, &switches, extension_bg_pages);
if (include_automation_extension) {
...
if (switches->HasSwitch("disable-extensions")) {
UpdateExtensionSwitch(switches, "disable-extensions-except",
automation_extension.value());
As mentioned in 54594305 Java code using selenium driver would be
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("useAutomationExtension", false);