Is there a way to bypass Chrome geolocation dialog in Protractor tests? - geolocation

I faced this problem, when automating an application with protractor.
Once I open a home page I get geolocation dialog with Block/Allow buttons, which didn't let proceed without selection either option
It turned out, that this dialog is not an instance of alert, that's why browser.switchTo().alert().confirm() didn't work
Passing '--disable-notifications' argument to Chrome also didn't solve the problem
Research online didn't give any positive results. How to solve it?

The solution to the problem is to pass "prefs": {'profile.default_content_setting_values.geolocation': 2} to capabilities object in your protractor.config.js
Below is another option that does pretty much the same thing.
So chrome may take an argument --user-data-dir=/tmp/chrome which specifies profile to open chrome with. If profile doesn’t exist at specified directory it creates default one.
Then if you open /tmp/chrome/Default/Preferences you’ll see an object with preferences. You needed to set default_content_setting_values.geolocation to 2 (not 1 or 0) to make it NOT prompt that dialog

Related

Find features of a non Microsoft program

I'm not sure how to even ask this question, but let's say I have a program such as Google Chrome. How would I find out the "features" of it so I can use PowerShell to modify it.
For example, how would I have Chrome open a web page and click a button.
I know for IE, you can use $ie.document.getElementById("loginform").submit() to click a button.
Thank you,
Tony
You can't ever really get the same amount of control over non-Windows programs using Powershell.
In terms of Chrome, you could simply open the browser and go to a webpage with:
$Start-Process "chrome.exe" "www.google.com"
There is generally not that much more for further functionality, but with Chrome you may be able to do things like change settings and configuration. Check out the (large) JSON file Preferences and other config files, which you can find in Chrome's local appdata folder (Win+R, %localappdata%, Google/Chrome/User Data/Default). I'm not too sure but it may also be a bad idea to mess around with these files.
I also did a Google search and found this third party powershell tool for browsers, called Selenium. Here's the list of extensions.

Display options.xul programmatically

I have an xul overlay based Firefox Add-on that works. It has inline options defined in content/options.xul and they display/function correctly when the user goes to Firefox->Add-ons->Extensions->{The Name of My Extension}->Options
The question, can I a create a button on my Add-on that will launch my options either by taking the user to Firefox->Add-ons->Extensions->{The Name of My Extension}->Options with one click or by launching a dialog based on options.xul?
Right now I am maintaining a separate options.html and options.js that gets and sets the same settings that options.xul handles when the user navigates there via the Firefox button but I would much rather dump options.html and options.js and only maintain my main.js and options.xul.
Any comments or code examples will be greatly appreciated.
This is easiest to do via a global function BrowserOpenAddonsMgr() defined in the browser window, like this:
BrowserOpenAddonsMgr("addons://detail/" + encodeURIComponent(addonID));
This function takes care of focusing the existing add-ons tab if there is one or opening a new tab. It will not scroll down to the options however which is an issue if the add-on has a lengthy description. Starting with Firefox 12 this can be solved by adding "/preferences" to the view identifier:
BrowserOpenAddonsMgr("addons://detail/" + encodeURIComponent(addonID) + "/preferences");
With older Firefox versions you are out of luck (and you shouldn't use this suffix there, it won't work). The other issue is that there can be a lengthy "loading" phase where the add-ons manager fetches metadata for all extensions.

Getting rid of double green lines in blog posts

I have a blog on Blogger, and sometimes, I notice that double green lines are automatically added below certain words, which will display an ad if you hover over it (see picture below). Is there a way I could permanently make these lines not show up (e.g. by adding code to the Blogger template)? I just noticed them being added to some of my posts recently, and I want them to go away forever.
This is most probably a browser plugin/gadget that is inserting these links, not Blogger. Disable, or better, uninstall the TextEnhance plugin/gadget .
See: http://wafflesatnoon.com/2011/10/05/seeing-unwanted-text-enhance-ads/
I was having the same text-enhance issue. It was installed on Chrome under the extension Premium-play codec c. Deleting the ext got rid of the adware.
To de-install this trojan horse, follow these steps:
De-install the following program(s) (go to the 'Add/Remove' section in the Control Panel):
--Pando media enhancer
--I Want This!
2) Apps/extensions for Chrome
*To remove extensions, type chrome://extensions into the omnibox/address bar
*To remove apps, go to the New Tab page > Apps panel > right click app you want to remove
--Premiumplay Codec-C (extension)
--Yontoo Layers (extension?)
--Rewards Gaming (app)
For Internet Explorer, disable the same extension(s).
I hope this helped banish this software from the internet.
Best regards and good luck!
When you get a pop-up, click on the name of the company that conducts the ads and you will go to their corporate site that has a disable link and it will effectively disable these links in any page that the company conducts business. Close and reopen browser and you will no longer see double line ads from that company anywhere on the internet. If you clear your cookies you will have to repeat this step, However, this is an easy way to stop the ads without corrupting your OS or browser. If you have to hack code and you don't know what you are doing you can damage a program or your computer beyond repair...If you know what you are doing then go forth and hack away.

Google Chrome Extension: Print the page silently

I'm developing an internal Google Chrome Extension that needs a way to initiate print the current page to the printer. I do not want the default Print dialog to come up (so, javascript:window.print() is out of question).
As far as I understand, this is not possible just with the JS + HTML plug-in, so I'm also open to using the NPAPI plugin also (with a dummy mime-type). And I'm concerned for Windows platform only.
I'm also open for various hacks / workarounds if possible, though a standard solution would be nice.
If you think this is not possible, let me know if you know any feature request logged for it?
Any suggestions/clarifications are welcome..
In chrome (v18+) we have the --kiosk --kiosk-printing switches. One can print automatically to default printer without print confirmation.
You can see it from this video http://www.youtube.com/watch?v=D6UHjuvI7IE
Since NPAPI allows you to create native C++ plugins that you can interact with through an object tag (which you can use from an extension), that would probably be the way to do it.
The tricky bit is that I don't know of a good way to get the bits for printing the page. The only person I know of who has done something similar to this actually got the window handle for the browser (available through NPAPI) and scraped the bits off of it to print that way, but that won't take into account print stylesheets or anything. You could also try using automation events to try to control the print dialog, but I have no idea if that would work or not.
By design, the browsers try not to let you do something like this, as it could open some serious vulnerabilities if any website could just start printing things to your printer without confirmation...
Anyway, if you find a way to do it with C++ you can use FireBreath to ease the creation of the NPAPI plugin.
There are various extensions that take snapshots of the current web page (for example, this one); you could adapt one to send the image to a printer via an NPAPI plugin.
I've recently been looking for a similar ability, and it seems like it would be quite possible using Chrome's new native messaging api.
https://developer.chrome.com/extensions/nativeMessaging
There are plenty of examples of this with C#, but here is one quick example of troubleshooting Chrome native messaging with a basic C# application
Native messaging from chrome extension to native host written in C#
I realize this may be a day late and a dollar short, but in case anyone else comes across this question, this is the solution that worked for me. From inside a C# app, you can directly print to installed printers using the PrintDocument class. If you figured out a way to get the page image, this would be far easier than using firebreath or NPAPI.
Disable print preview in Google Chrome on Mac
Quit Google Chrome
Launch Terminal on your Mac. (Search “Terminal” using the Search box)
Type defaults write com.google.Chrome DisablePrintPreview -bool true
Close Terminal and open Google Chrome
Disable print preview in Google Chrome on Windows
Close Google Chrome
From your desktop, right click Google Chrome
Click Properties
In the dialog box, add ‘ –disable-print-preview‘ at the end of the Target field sans the apostrophe (make sure to include the space before –)
Click Apply
Disable print preview in Firefox on Mac
In the address bar type “about:config” and press Enter.
Right click on the page, hover over ‘New’ and click on ‘Boolean’
Type ‘print.always_print_silent’ as the preference name and click ‘OK’
Click on ‘true’ and click ‘OK’.
Close the about:config window.
Disable print preview in Firefox on Windows
In the address bar type “about:config” and press Enter.
Right click on the page, hover over ‘New’ and click on ‘Boolean’ Type
‘print.always_print_silent‘ as the preference name and click ‘OK’
Click on ‘true’ and click ‘OK’.
Close the about:config window.
https://support.dryfta.com/how-to-disable-print-preview-in-chrome-firefox-on-windows-mac/

Testing multiple concurrent browser sessions

I'm developing a card-game in Ruby on Rails, and trying to work out how best to test it.
When a player joins a game, their Player object is stored in the session. Obviously, in order for the game to work, I need more than one Player in a game at once. Since sessions are the same for different tabs in one browser, I'm currently testing a 2-player game by having the app open in FireFox and Internet Explorer at the same time.
Before I go off and download Chrome in order to test a third player... is there an easier way of doing this?
Edit: To clarify, I'm not yet at the stage where I want to run automated tests to see if it breaks. I'm at the stage where I want to be able to hack the back-end db, then refresh the page and see how it looks now, or click a button to see the (usually) failure response, or whether the behaviour is looking right.
You can run Firefox with multiple profiles. From a command line go to the directory Firefox is installed in and run firefox -P. Create a profile for every instance that you want to run. Close the profile manager, then for each profile run firefox -no-remote -P "profile name". You can run as many instances of Firefox as you want, and each one runs with an independent profile and thus independent session.
Automate it!
You really don't want to be manually testing this. You could use a Ruby script with the curl libs to generate the 'moves' and manage the response including the session cookie.
As a teaser, see this snippet from the API docs, sounds like it would help you..
easy.cookiejar = "cookiejar.file" => "pwd string"
Set a cookiejar file to use for this Curl::Easy instance.
This file will be used to persist cookies.
Use http://watir.com/ to create ruby scripts exercising your game.
Use multiple Watir::Browser instances to run multiple browsers.
Use firefox' profiles and -no-remote switch to keep them separated. See also this question.
Rather than opening a new tab, create a new window in your Web browser. The new window will have its own session. This works for Internet Explorer, but not for Firefox. I haven't tested it in the WebKit based browsers.

Resources