Codeceptjs Headless tests with https do not work - selenium

When i run tests with https headless, the error below shows up
bash
Error: move target out of bounds: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
Running without --headless option, it works but slower.
Running as http with --headless works too
CodeceptJS version: newest
NodeJS Version:4.2.6
Operating System: Mint
WebDriverIO: newest
Configuration file:
```json
{
"tests": "./**/*_test.js",
"timeout": 10000,
"output": "output",
"helpers": {
"WebDriverIO": {
"smartWait": 50,
"url": "https://172.17.0.1/",
"browser": "chrome",
"restart": false,
"desiredCapabilities": {
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless"]
}
}
}
},
"include": {
"I": "./steps_file.js",
"loginPage": "./pages/Login.js",
"defaultData": "./Data/defaultData.js",
"registerPage": "./pages/Register.js",
"menu": "./pages/Menus.js",
"profilePage": "./pages/Profile.js",
"subscription": "./pages/Subscription.js",
"recordsPage": "./pages/Records.js"
},
"bootstrap": true,
"name": "CodeceptJS",
"plugins": {
"allure": {
"enabled": "true" }
}
}
```

Try using an x instead of a comma (,) when specifying the window size.
Example:
--window-size=1920x1080

Maybe this is related to this:
https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-document
You could create Chrome profile where you will turn off this option and load it by providing run parameter (https://chromium.googlesource.com/chromium/src/+/HEAD/docs/user_data_dir.md):
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless",
"--user-data-dir=<YOURDIR>]
}
Another solution you could check if UserAgent string for headless is different than normal browser, and if answer is yes override it with (Chrome 69 UA):
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless",
"--user-agent="Mozilla/5.0 AppleWebKit (KHTML, like Gecko) Chrome/69.0 Safari"]
}
And the last one is to turn off security policy by providing parameters:
--disable-web-security
--allow-running-insecure-content
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless",
"--disable-web-security",
"--allow-running-insecure-content"]
}
You can try one of the possible solutions or combine them.

Related

How can i custom config CHANGELOG.md using standard-version npm package?

I'm using the command standard-version each time I want to publish new version, but the yielded changes in the CHANGELOG.md look like this:
### [10.1.9](https://github.com/my-project-name/compare/v10.1.8...v10.1.9) (2021-03-29)
### [10.1.8](https://github.com/my-project-name/compare/v10.1.7...v10.1.8) (2021-03-29)
### [10.1.7](https://github.com/my-project-name/compare/v10.1.6...v10.1.7) (2021-03-29)
first the links do not work - the github url is not correct and i want to configure it to the right url, and second, I'd like to configure the link that's shown in the changeslog file (there are some types)
I tried to use this documentation but didn't find anything that can help me
https://github.com/conventional-changelog/conventional-changelog
so how do I configure the way standard-version works on the CHANGELOG.md ? can someone provide example?
yes.
according to doc:
You can configure standard-version either by:
Placing a standard-version stanza in your package.json (assuming your project is JavaScript).
Creating a .versionrc, .versionrc.json or .versionrc.js.
If you are using a .versionrc.js your default export must be a configuration object, or a function returning a configuration object.
Any of the command line parameters accepted by standard-version can instead be provided via configuration.
Please refer to the conventional-changelog-config-spec for details on available configuration options.
example:
.versionrc
{
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"hidden": true
},
{
"type": "docs",
"hidden": true
},
{
"type": "style",
"hidden": true
},
{
"type": "refactor",
"section": "Refactor"
},
{
"type": "perf",
"section": "Performance"
},
{
"type": "test",
"hidden": true
}
]
}

Error when running Selenium Server via Nightwatch

I'm attempting to run a simple test script. But I receive the following error:
I have my nightwatch config file setup as so:
nightwatch.conf.js
module.exports = {
"src_folders": [
"tests"// Where you are storing your Nightwatch e2e/UAT tests
],
"output_folder": "./reports", // reports (test outcome) output by nightwatch
"selenium": {
"start_process": true, // tells nightwatch to start/stop the selenium process
"server_path": "./node_modules/selenium-standalone/.selenium/selenium-server/2.53.1-server.jar",
"host": "127.0.0.1",
"port": 4444, // standard selenium port
"cli_args": { "webdriver.chrome.driver" : "./node_modules/selenium-standalone/.selenium/chromedriver/2.25-x64-chromedriver"
}
},
"test_settings": {
"default": {
"screenshots": {
"enabled": true, // if you want to keep screenshots
"path": './screenshots' // save screenshots here
},
"globals": {
"waitForConditionTimeout": 5000 // sometimes internet is slow so wait.
},
"desiredCapabilities": { // use Chrome as the default browser for tests
"browserName": "chrome"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true // set to false to test progressive enhancement
}
}
}
}
guinea-pig.js
module.exports = { // addapted from: https://git.io/vodU0
'Guinea Pig Assert Title': function(browser) {
browser
.url('https://saucelabs.com/test/guinea-pig')
.waitForElementVisible('body')
.assert.title('I am a page title - Sauce Labs')
.saveScreenshot('ginea-pig-test.png')
.end();
}
};
The server path and chromedriver path are accurate and the most recent copy. I also have the latest version of chrome installed. Can someone please help me understand what could be the problem? Thanks!
Edit: I've also restarted the whole computer, same issue.
Try using the latest version of the Selenium standalone server v.3.0.1
If that doesn't work, then you can upgrade your chromedriver to the latest version and test. You can find the different versions here:
https://chromedriver.storage.googleapis.com/index.html
Also make sure you are using the most recent version of Nightwatch v0.9.9 and update it in you package.json file.
It is written very clear , your chrome version is lower than what chromedriver needs, just update your chrome to the latest version

Can nightwatch.js use usingServer from selenium-webdriver?

I have a suite of tests using local drivers built with nightwatch. Works well.
I am running a basic test using Perfecto Mobile and selenium-webdriver. It works with this example.(https://community.perfectomobile.com/series/20208/posts/1002862)
I am trying to connect my suite of nightwatch test to perfecto, but can't start selenium. If this is the url of the selenium server.
var url = "https://mobilecloud.perfectomobile.com/nexperience/perfectomobile/wd/hub";
I tried a few ways to set it up under nightwatch config, but can't make it work.
"selenium" : {
"start_process" : true,
"host" : "mobilecloud.perfectomobile.com/nexperience/perfectomobile/wd/hub"
}
Is there an equivalent to usingServer in nightwatch? I haven't seen anything in the docs.
driver = new webdriver.Builder().
usingServer(url).
withCapabilities(capabilities).
build();
Turns out this was the setup needed.
"test_settings" : {
"perfecto" : {
"use_ssl": true,
"default_path_prefix": "/nexperience/perfectomobile/wd/hub",
"selenium_port" : 443,
"selenium_host" : "mobilecloud.perfectomobile.com",
"desiredCapabilities": {
"browserName": "xxx",
"deviceName": "xxx",
"user": "xxx#xxx.xxx",
"password": "xxx",
"platformName": "xxx"
}
}
}
The important part that didn't work at the time of writing the question: the default_path_prefix was not customizable.
/wd/hub was the default prefix. But I really needed /nexperience/perfectomobile/wd/hub.
Two days later, this commit was introduced. It is available in 0.9.5 release.
https://github.com/nightwatchjs/nightwatch/commit/aa24c2c2334c42388318498f654d8fe2957967d1

Setting up a node on a VM

I have my selenium all configured but seem to be having issues getting it to launch the browser on my windows VM. I think it's because I haven't haven't included the correct path to the driver. Currently it stands as...
java -jar .\selenium-server-standalone-2.39.0.jar -role node -port 1001 -hub http://xxx.xxx.xx.xxx:4444/grid/register
After reading online I assumed it's cause I'm missing the following...
-Dwebdriver.ie.driver="C:\selenium\IEDriverServer.exe"
I've tried various different ways to include this path into the above statement but keep getting 'poorly formatted Java property setting (I expect to see '=') -Dwebdriver: Usage: java -jar selenium-server.jar [-interactive] [options]'
if anyone could show me the correct format I'd really appreciate it.
Thanks.
According to documentation, you can use a system property:
System.setProperty("webdriver.ie.driver", "C:\selenium\IEDriverServer.exe")
Of course this path would have be the correct on the remote machine!
If you use Maven for your builds, then the Selenium binary downloader might interest you.
I would suggest running the node and having the node load a .json config file that looks something like this.
{
"capabilities":
[
{
"browserName": "firefox",
"acceptSslCerts": true,
"javascriptEnabled": true,
"takesScreenshot": false,
"firefox_profile": "",
"browser-version": "31",
"platform": "WINDOWS",
"maxInstances": 5
},
{
"browserName": "chrome",
"maxInstances": 5,
"platform": "WINDOWS"
},
{
"browserName": "internetExplorer",
"maxInstances": 1,
"platform": "WINDOWS"
}
],
"configuration":
{
"_comment" : "This is configuration for the grid node 1.",
"cleanUpCycle": 2000,
"timeout": 30000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"port": 5555,
"host": ip,
"Dwebdriver.chrome.driver=C:\\Selenium\\chromedriver.exe": "",
"Dwebdriver.ie.driver=C:\\Selenium\\IEDriverServer.exe": "",
"register": true,
"hubPort": 4444,
"maxSessions": 5
}
}

composer to disable https completely

my network does not work well with https, so doing
composer.phar install
throws
[Composer\Downloader\TransportException]
The "https://packagist.org/packages.json" file could not be downloaded: Failed to enable crypto
failed to open stream: operation failed
i used
{
"packagist": false
},
{
"type": "composer",
"url": "http://packagist.org",
"options": {
"ssl": {
"verify_peer": "false"
}
}
}
as a http falback, but again it crashes in some other point:
Installing dependencies
- Installing symfony/translation (v2.4.0)
Downloading: 100%
Downloading: 100%
Downloading: 100%
[Composer\Downloader\TransportException]
The "https://api.github.com/repos/symfony/Translation/zipball/0919e0fc709217f8c9e5049f2603419fdd4a34ff" file could not be downloaded: Failed to
enable crypto
failed to open stream: operation failed
my problem is just with TLSv1, previous SSL versions should work, as the browsers work correctly.
how should i do, the problem also exists in other cmd tools that depend on https like npm, bower, git, curl, ...
composer config --global disable-tls true
composer config --global secure-http false
You can turn off TLS (For your specific project) using your composer.json as such:
{
"require": {
"laravel/framework": "5.2.43"
},
"config": {
"preferred-install": "dist",
"disable-tls": true,
"secure-http": false
}
}
NB: Take not of the "disable-tls": true in the config section.
The problem is simply that you wrapped "false" in quotes, which is true when converted to bool.
Use "verify_peer": false instead of "verify_peer": "false":
{
"repositories": [
{
"type": "composer",
"url": "http://packagist.org",
"options": {
"ssl": {
"verify_peer": false
}
}
}
]
}
It's okey.
It will work. You just have a mismatch:
"options": {
"ssl": {
"verify_peer": false
}
}
in order to disable https totaly (not recommanded)
you need to add "secure-http": false in your composer.json file config key like this:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "5.3.*",
},
...
"config": {
"preferred-install": "dist",
"bin-dir": "vendor/bin/",
"secure-http": false
},
"minimum-stability": "dev"
}
You cannot disable SSL with Composer. Even if it works like in your setup, you cannot control the source URLs of any package you use. Some of them do not offer anything without SSL, so you MUST use SSL.
I think it's the best idea to make SSL work. Did you try composer diag and see where the problem is?