shardTestFiles unexpected behaviour with chromeoptions setting of --user-dir-data - google-chrome

I have the following settings in my config file.
specs : ['../specs/sample1.js', '../specs/sample2.js']
capabilities : {
'browserName' : 'chrome',
'chromeOptions' : {
'args' : [ '--user-data-dir=C:/Chrome/User Data' ]
},
shardTestFiles: true,
maxInstances: 2
}
There is nothing special about the tests in the spec file, just prints out the title of the url in the console.
When I run the test two chrome windows are opened up. But only one
(random choice) of the spec file tests are run. Once the tests in that spec file are completed both the browsers close at the same time. The second spec file is orphaned out and errors out after some time. Both the browser icons are overlapping each other. Check image below.
When I comment out the args in chromoptions containing the user-data-dir option, everything works perfectly. Two chrome windows are opened and the spec files are divided among the two browser windows and run all tests to completion. In this case the browser icons are separate.
I want to use the existing chrome profile with parallel option as it speeds up page loading and has default cookies setup.
What is the solution to get this to work?
On latest versions of protractor, chrome, webdrivers running on windows 8

Related

Where is Electron (or Chrome) saving the zoom setting?

In my electron app menu I am using the built-in zoomin/zoomout roles. (The menu code being used is pasted in at the end of this question.) I start the app, choose zoom-in, then close the app. When I start it again, it starts at that already zoomed in setting.
Where is it saving this configuration? There is no hidden file being created or modified in the application directory, or below. I wondered if it might be something about my development environment, so I built the Linux package, and ran that, but the behaviour is the same.
Another question I've had is where the Chrome debugger saves the breakpoints (and other debug configuration) between runs of my electron app, and now I'm wondering if the zoom setting is also a Chrome thing? However, I've checked and it appears to be saving these settings per-application: if I set the zoom in the development environment, it has not affected the zoom when I start the packaged version.
(To be clear, this is not a bug I'm trying to fix - in fact I'd class it as a feature - but I would like to understand what setting files my Electron app is reading/writing, beyond the ones I am explicitly creating.)
{
label: 'View',
submenu: [
{role:'resetzoom'},
{role:'zoomin'},
{role:'zoomout'},
{type:'separator'},
{role:'togglefullscreen'},
]
}

What is the difference between manually opened Chrome browser and opened using chrome driver

I am using Selenium for automating the chrome browser. When I download the files using automated Chrome browser it gives me a warning,
'This type of file can harm your computer' with keep or discard options.
But when I manually open chrome and download the files from same site, I won’t get any warnings.
I know I can disable the warnings using, options.AddUserProfilePreference("safebrowsing.enabled", true);
But my question is why I am getting this warning only in automated window?
What is the difference between browser opened using Chrome driver and manually opened browser?
Please help me.
If during your manual download, in your chrome
Settings > Advance Settings
Privacy -> Protect you and your device from dangerous sites (is_checked)
The download warning wouldn't be displayed on your browser.
On the other hand, not all chrome options are set to the same value during automatic download from your code. Hence you need to specify :
options.AddUserProfilePreference("safebrowsing.enabled", true);
List of all command line arguments for chrome driver goes here.
Note : Though not all of them are certainly of use while using automation and not all of them correspond to a chrome manual setting either.

Chrome 33 does not allow video capture although allowed in Preferences

I am trying to allow a http website to use my camera without the prompt without luck.
I changed the Preference file (when Chrome is closed) and changed the Profile part as follows:
"profile": {
"avatar_index": 0,
"content_settings": {
"clear_on_exit_migrated": true,
"pattern_pairs": {
"http://mywebsite.com:80,*": {
"media-stream-camera": 1,
"media-stream-mic": 1
},
...
However, for some reason it keeps showing the prompt.
Any idea? I'm using Chrome version 33.
Thanks!
It seems like Chrome overwrites the preference file every time it starts. I couldn't get any of my changes to stick.
Solution 1. Packaged Chrome app.
One way to grant permissions is to run your site as a chrome app. Just include videoCapture in the manifest.json. This will definitely work.
"permissions": [
"videoCapture"
],
Solution 2. Get an SSL Certificate.
I know you specifically said 'http', but if you have serve your site over https, it will only require the user to grant permissions once.
Solution 3. Modify device policy.
If you can't package your site as a chrome app for some reason, there might be another way to get it to work. It involves editing Chrome's policy list to allow camera access. I can't get this to work, currently, but I'm looking into it.
http://www.chromium.org/administrators/policy-list-3#VideoCaptureAllowedUrls
VideoCaptureAllowedUrls are a list of urls to automatically grant webcam permission to. The problem is setting this property. I know where the file lives, but there are no examples on HOW to set properties.
/Applications/Google\ Chrome.app/Contents/Resources/com.google.Chrome.manifest/Contents/Resources/com.google.Chrome.manifest
There are 'instructions' on editing the policy list, but they're totally useless. All it does is point to that file, and gives templates for Windows and Linux (I'm on OSX).
Note that this solution will only work in kiosk mode. To run Chrome in kiosk mode, add the flag --kiosk http://yoursite.com. This forces the app into fullscreen mode.
If you're on Windows/Linux, this SO post might help you.
Solution 4. Use command-line flag
use --use-fake-ui-for-media-stream command-line flag
example (OS X) : /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome http://html5-demos.appspot.com/static/getusermedia/record-user-webm.html --use-fake-ui-for-media-stream
More info here http://creativcoders.wordpress.com/2014/08/18/chrome-always-allow-access-to-webcam-and-microphone-over-http-webrtc/

Chrome --load-extension doesn't work on some machines

I'm trying to load unpack extension using command line flag --load-extension.
I'm using one chrome profile. The syntax for query is following:
chrome --load-extension="C:\Users\someUser\Desktop\unpackExtensionFolder"
Inside unpackExtensionFolder there is manifest.JSON and all sources.
This command doesn't work on few PCs in office, but it works on the rest of them, and successfully loads the extension (Chrome version is the same on all machines - 31, extension that we are trying to load is the same).
Discovered:
Doesn't depend on chrome profiles amount
Doesn't depend on developer mode on/off
The question is why? And what could have influence on this?
The reason for this was plugin inside manifest file, seems that chrome was not able to load extension with plugin declarated in it. Works fine after removing plugin section.

HTML5 offline "Application Cache Error event: Manifest fetch failed (-1)"

I'm trying to write an HTML5 offline application but can't seem to get Chrome to accept the cache manifest file.
Chrome logs the following output to its console while loading the application:
Creating Application Cache with manifest http://localhost/cache.manifest
Application Cache Checking event
Application Cache Error event: Manifest fetch failed (-1) http://localhost/cache.manifest
However, if I remove all lines from the manifest file except for the first line (i.e. "CACHE MANIFEST") Chrome accepts the manifest:
Creating Application Cache with manifest http://localhost/cache.manifest
Application Cache Checking event
Application Cache Downloading event
Application Cache Progress event (0 of 0)
Application Cache Cached event
But, as soon as I add a new line to the manifest (even if that next line is empty) Chrome reverts to complaining that the fetch failed.
All files are being served locally from a Windows 7 PC via Python using SimpleHTTPServer on port 80. I've updated the types_map in %PYTHON%/Lib/mimetypes.py with the following line:
'.manifest': 'text/cache-manifest',
The manifest should contain the following:
CACHE MANIFEST
scripts/africa.js
scripts/main.js
scripts/offline.js
scripts/libs/raphael-min.js
favicon.ico
apple-touch-icon.png
To cache a website offline (HTML5) you need to specify all the files needed for it to run. In short specify the site main components needed.
Easy way to create a manifest is in Note Pad.
Note: CACHE MANIFEST needs to be first line and your files will follow after a line space as follows:
CACHE MANIFEST
Scripts/script.js
Content/Site.css
Scripts/jquery-ui-1.8.20.min.js
Scripts/modernizr-2.5.3.js
SESOL.png
Scripts/jquery.formatCurrency-1.4.0.min.js
http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css
http://code.jquery.com/jquery-1.8.2.min.js
http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js
Content/themes/images/icons-18-white.png
Controllers/AccountController
Controllers/HomeController
Models/AccountModels
Account/Login
Home/CheckOut
Note2: remove all spaces after each line.
Note:3 you need to follow the exact format FOLDER/File or FOLDER/FOLDER/FILE ect....
Just because you have a manifest file doesnt mean it will load. you need to add the following to the Tag:
<html manifest="~/cache.manifest" type="text/cache-manifest">
Don't forget that after you add this it's cached the first time the page loads. So you need to register a cache event in the 'mobileinit' event.
$(document).on("mobileinit", function () {
//register event to cache site for offline use
cache = window.applicationCache;
cache.addEventListener('updateready', cacheUpdatereadyListener, false);
cache.addEventListener('error', cacheErrorListener, false);
function cacheUpdatereadyListener (){
window.applicationCache.update();
window.applicationCache.swapCache();
}
function cacheErrorListener() {
alert('site not availble offline')
}
}
Download Safari and use the web inspector to find errors.
http://developer.apple.com/library/safari/#documentation/appleapplications/Conceptual/Safari_Developer_Guide/1Introduction/Introduction.html#//apple_ref/doc/uid/TP40007874-CH1-SW1
Tip: Chrome's developer tools "F12" will show you the errors in the manifest load. ie the files you still need to add.
Hope this helps, covers the entire process. I assuming if you are at this stage in development you new to add these to the mobile init:
$.mobile.allowCrossDomainPages = true; // cross domain page loading
$.mobile.phonegapNavigationEnabled = true; //Android enabled mobile
$.mobile.page.prototype.options.domCache = true; //page caching prefech rendering
$.support.touchOverflow = true; //Android enhanced scrolling
$.mobile.touchOverflowEnabled = true; // enhanced scrolling transition availible in iOS 5
Safari Developer Guide:
https://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/Client-SideStorage/Client-SideStorage.html#//apple_ref/doc/uid/TP40002051-CH4-SW4
Have you tried anything like https://manifest-validator.appspot.com/ to validate your manifest?
I've struggled with my manifest file for quite a while, it is really hard to pinpoint what is wrong. Could be something as simple as wrong encoding to an extra line break at the start.
Today I experienced exactly the same problem. After hours of working I came the the key point: the format of manifest file. In short, the file must begin a new line ONLY with ascii(0A), not ascii(0D), or ascii(0D + 0A). Only in this way can I live with Chrome, or I will get a blank page, and the error info in the console window.
According to w3c, (http://www.w3.org/TR/html5/offline.html), in “5.6.3.2 Writing cache manifests”,both 0A, 0D and 0D + 0A are all acceptable. So, my opinion is: Chrome is not compatible with w3c in the point.
Further more, say, if myapp.js is to be cached, it MUST follow the same rule: begins a new line only with ascii(0A), or Chrome will throw the same info in the console windows.
My Chrome is 13.0.782.107
I have now resolved this issue by switching to CherryPy for serving these files :)
If anyone else becomes similarly stuck but wants to keep the server part simple, the following Python may be sufficient for getting started:
import cherrypy
class SimpleStaticServer:
#cherrypy.expose
def index(self):
return '<html><body>Go to the static index page</body></html>'
cherrypy.config.update({
# global
'server.socket_host': '192.168.0.3',
'server.socket_port': 80,
# /static
'tools.staticdir.on': True,
'tools.staticdir.dir': "(directory where static files are stored)",
})
cherrypy.quickstart(SimpleStaticServer())
If you want to visit the "site" from another device, you'll need to use the external IP address (for me this was 192.168.0.3). Otherwise, you can just use '127.0.0.1' for the 'server.socket_host' value. I then point my browser to http://192.168.0.3/index.html to get my static index page.
I have resolved this issue in visual studio for MVC application.
follow below steps:
I have created .appcache file in notepad and copy manifest file content into it.
(you don't need to create .Manifest file OR not create Manifest.cshtml view. just create .appcache file in notepad.)
give reference as
<html manifest="~/example.appcache"> in view
and issue will be resolved
I think the line
CACHE:
is missing in the manifest file (should be the 2nd line, before the list of files.