Unable to hide “Chrome is being controlled by automated software” infobar within Chrome v76 - selenium-chromedriver

This is not really a new question, nor an answer to the original question, but is rather a request for clarrity since the answer posted to the original question is incomplete, but any request for clarrity gets deleted...
Original post is here... Unable to hide "Chrome is being controlled by automated software" infobar within Chrome v76
So, while I understand your original answer, we do not use managed instances of Chrome, and we all run on Windows 10 Home Edition... so, this setting your answer is not an option for us. On the other hand, all of our regression tests are failing now because this stupid banner is in the way of everything.
Is there a way a non-IT-Managed user running Windows 10 Home Edition can suppress this banner?
If not, how does Google expect us to continue using Chrome for testing? Any suggestions greatly appreciated... Also, I am using Python, so if you supply code example, please keep that in mind... this is what I am currently doing, and it was working before last week, but not working now...
options = webdriver.ChromeOptions()
options.add_argument('--start-maximized')
options.add_argument("--disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument("--disable-automation")
options.add_argument("--log-level=3")
# options.add_argument('headless')
options.add_argument('window-size=1920x1012')
options.add_experimental_option("prefs", {"download.prompt_for_download": False})
options.add_experimental_option("prefs", {"plugins.plugins_list": [{"enabled": False, "name": "Chrome PDF Viewer"}]})
options.add_experimental_option("prefs", {"download.default_directory": os.path.abspath(context.BaseResultsDir + '/Downloads/')})
options.add_experimental_option("prefs", {"download.extensions_to_open": "applications/pdf"})
context.driver = webdriver.Chrome(chrome_options=options)

After much Googling, this is finally what worked for me... Updated Selenium, switched to Canary release of ChromeDriver, and then made these adjustments to my test code, which is Python...
# options.add_argument("--disable-infobars") <<< TOOK THIS OUT
# options.add_argument("--disable-automation") <<< TOOK THIS OUT
options.add_experimental_option("excludeSwitches", ["enable-automation"]) <<< PUT THIS IN (Finding this one was the real killer)
options.add_experimental_option("useAutomationExtension", False) <<< PUT THIS IN
Your solution and mine are very similar. Thank you for posting.
David

Probably reason behind settings for infobar was working still last week not in this week, are may be you have updated/autoupdated chromedriver or chromebrowser. However your setting to disable infobar are not working because as per this commit on - Jan 10 2018, --disable-infobars option has been removed from chrome options
Solutions - Keeping this line does nothing options.add_argument("--disable-infobars") you can remove it.
options.add_argument("--disable-automation")
This line makes real confusion here towards the solution because there are 2 different ways to do it (By default this switch is enabled we have to remove it to disable the infobar). This line disables the password saving UI for more details read this nice discussion
Use this line do disable the infobar by excluding enable automation switch -
options.add_experimental_option("excludeSwitches" , ["enable-automation"])
It solves the problem to some extent, when I tried with this intermittently developer code plugin popup comes up and ask to enable/disable it. and it wont go away by options.add_argument("--disable-extensions") this. If you facing same issue use another switch to disable it as below-
options.add_experimental_option("excludeSwitches" , ["enable-automation","load-extension"])
This solves the problem from root(load-extension switch supports Chromedriver v2.33 and later). However there is one more way to disable the developer code plugin popup which you can do by adding --disable-plugins into shortcut of chrome
If these solutions doesn't work for you then chromium command line switches here can help you to customize the chrome behavior
Additionaly ChromeDriver(Capabilities capabilities) is deprecated and can be used as
capabilities = DesiredCapabilities.CHROME.copy()
capabilities.update(options.to_capabilities())
driver = webdriver.Chrome(chromedriver, desired_capabilities=capabilities)
solution to disable infobar in Java
options.setExperimentalOption("excludeSwitches", Arrays.asList("enable-automation" , "load-extension"));
will disable infobar with developer code plugin

This worked for me:
options.add_option('excludeSwitches', ['enable-automation'])
Method add_experimental_option, I suppose, is removed from the latest versions.

Related

Chrome on startup to continue where I left off and one more page

Whenever I open chrome, I want:
All my previous pages are there
Another page, with a custom URL, is there. (With the possibility of me setting it to be chrome://newtab.)
Is this possible?
Is there a way that on open specific set of pages, I can add previous pages?
I have tried looking. The closest thing I could find was this. This is not exactly what I wanted.
I would like a simple and easy way of doing this. (I don't mind extensions but I couldn't find any.)
I want this to be done without any input from me every time. So no CtrlShiftT please.
Thank you in advance.
If you need to automate Chrome GUI, it's possible using pywinauto. My student wrote an example dragging file from explorer.exe to Google Disk opened in Chrome. There are some tricks used here.
test_explorer_google_drive.py
Chrome requires command line parameter --force-renderer-accessibility to enable MS UI Automation support in Chrome. So if you're starting Chrome it should work for you. If you're trying to connect to existing Chrome window this might be a problem.
Need to use backend='uia' explicitly for pywinauto.Application object. See the Getting Started Guide for more details, core concept and other useful things.
The relevant part of the mentioned script:
from pywinauto import Application
chrome_dir = r'"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"'
# start Chrome
chrome = Application(backend='uia')
chrome.start(chrome_dir + ' --force-renderer-accessibility --incognito --start-maximized <URL>')
# wait while page is loading (up to 10 sec.)
chrome['<Tab caption>'].child_window(title_re='Reload.*', control_type='Button').wait('visible', timeout=10)
the details of this may depend on your operating system but on windows I can access a "master_preferences" file in C: > Program Files > Google > Chrome > application.
the contents of the file looks like:
{
"homepage": "http://www.google.com/",
"homepage_is_newtabpage": false,
"distribution": {
"suppress_first_run_bubble": false,
"import_search_engine": false,
"import_history": false,
"do_not_launch_chrome": true,
"make_chrome_default": false,
"verbose_logging": false,
"ping_delay": -60
},
"sync_promo": {
"show_on_first_run_allowed": false
},
"session": {
"restore_on_startup": 4,
"startup_urls": ["http://www.google.com/"]
},
"first_run_tabs": ["http://www.google.com/", "http://welcome_page"]
}
You can see there are settings for restore_on_startup
and startup_urls under the "session" heading
try editing those settings so the look like this:
"restore_on_startup": 2,
"startup_urls": ["http://www.google.com/", "http://www.theurlyouwant.com"]
You may not be able to configure these settings on your work or school computer as it requires administrator privileges. And also if you're not familiar with JSON pay especial close attention to the syntax (commas, quotation marks etc) I've used in my examples.
I don't know if this will help, it's certainly not as technical a response as everyone else, but I use the OneTab Chrome extension to do some of the stuff you're talking about.
I have a handful of pages saved to it, and I click the Restore All button and they all load in. You can save groups of tabs, and lock those groups so they're not easily deleted on accident, and name groups of saved tabs as well. I think it's pretty helpful, but it might not be exactly what you need/are looking for. Hope it helps though!

Disable Chrome address bar autosearch for dev

Developing a web app locally and I just can't get Chrome to actually go to this address, because auto search always kicks in (http://0.0.0.0:5000/api works though, for example).
Is there a way to overwrite this behaviour or force Chrome to try a http request first, before anything else?
I am aware I can just curl it or whatever to see the response...
Go to chrome://omnibox/ and check [x] Prevent inline autocomplete
The answer to this has to be in chrome://chrome-urls
you should see something like the following:
The "full" set of settings is on the chrome://chrome-urls . Also chrome://flags is worth to check. As a side by enabling some experimental features from chrome://flags you can greatly enhance your browsers HTML5 support which can be checked at HTML 5 support .
else:
Clear browser historythen go to settings and under Privacy --> uncheck [] Use a prediction service to help complete searches and URLs typed in the address bar .
Another idea is to examine carefully if using linux the output of the following command for parameters:
ps -aux | grep google-chrome-stable
in my case the output tells me a lot about what parameters are used at launch by default:
/opt/google/chrome/chrome --type=renderer --disable-layer-squashing --enable-transition-compositing --enable-deferred-image-decoding --enable-display-list-2d-canvas --enable-distance-field-text --enable-encrypted-media --enable-experimental-canvas-features --enable-experimental-web-platform-features --enable-lcd-text --enable-one-copy --enable-overlay-scrollbar --enable-renderer-mojo-channel --enable-smooth-scrolling --enable-viewport-meta --enable-webgl-draft-extensions --enable-web-midi --enable-zero-copy --max-tiles-for-interest-area=512 --enable-plugin-power-saver --lang=en-US --force-fieldtrials=AutoReloadExperiment/FlagEnabled/AutoReloadVisibleOnlyExperiment/FlagEnabled/ChromeSuggestions/Default/DomRel-Enable/enable/EnhancedBookmarks/Default/ExtensionContentVerification/Enforce/ExtensionInstallVerification/None/GCM/Enabled/MaterialDesignNTP/Enabled_forced/OmniboxBundledExperimentV1/StandardR4/PasswordGeneration/Disabled/PrerenderFromOmnibox/OmniboxPrerenderEnabled/QUIC/FlagEnabled/SafeBrowsingIncidentReportingService/Default/SettingsEnforcement/no_enforcement/UMA-Dynamic-Binary-Uniformity-Trial/default/UMA-Population-Restrict/normal/UMA-Uniformity-Trial-1-Percent/group_09/UMA-Uniformity-Trial-10-Percent/group_02/UMA-Uniformity-Trial-100-Percent/group_01/UMA-Uniformity-Trial-20-Percent/group_04/UMA-Uniformity-Trial-5-Percent/group_16/UMA-Uniformity-Trial-50-Percent/group_01/UwSInterstitialStatus/OnButInvisible/VoiceTrigger/Install/WebRTC-IPv6Default/Default/ --enable-crash-reporter=9F2AFD26-85F1-40CB-991F-0980EF2C4D14 --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --enable-offline-load-stale-cache --enable-app-window-controls --enable-embedded-extension-options --enable-experimental-extension-apis --enable-scripts-require-action --enable-nacl --enable-nacl-debug --enable-streamlined-hosted-apps --enable-web-based-signin --javascript-harmony --out-of-process-pdf --enable-delegated-renderer --enable-impl-side-painting --num-raster-threads=4 --enable-gpu-rasterization --channel=5035.27.2136067136
Even yet another idea is maybe to write a small widget using python's tkinter and the webrowser modules, it could even get its input from the clipboard.
this command could be a work around solution too:
python -m webbrowser -t "http://ip.ip.ip.ip:portport/file/"
Another option yet is to use The Omnibox API and embed a custom omnibox in a simple webpage. Here are the omnibox api ready made samples.
You can avoid this by adding a "/" at the end of the URL http://0.0.0.0:5000/api/
or
You can try to add a null search engine with a URL of http://%s and null keyword.
Go to the search engine settings:
Open Settings.
Click Manage search engines
At the bottom of the Other search engines section add a new search engine.
Using #Juan Buhagiar answer as a starting point, I added your URL as the URL of a default search engine:
Other search engines
| MyAPI | 0.0.0.0 | http://0.0.0.0:5000/api/venues/show/45/20/cafes?rubbish=%s |
That just worked. The only drawback is that you get a redundant query to your request:
http://0.0.0.0:5000/api/venues/show/45/20/cafes?rubbish=0.0.0.0%3A5000%2Fapi%2Fvenues%2Fshow%2F45%2F20%2Fcafes%2F
instead of plain:
http://0.0.0.0:5000/api/venues/show/45/20/cafes
So as long as it does not conflict with your own GET, you can just ignore it.
Simplest way - Add a bookmark with your desired address. This time it will not goto search. This may not be useful if you have to change variables regularly, which was not my case.
This is helpful if you do not want it to disable omnibar search completely since it is quite a useful feature.

Close a single tab in Chrome using Batch command

I'm relatively new to batch commands and have been learning steadily. My problem is like this:
I've understood how to kill processes using batch commands using many different methods. However, I've been unable to figure out how to close a single tab in, preferably, chrome.
Any thoughts would be greatly appreciated!
Thanks!
So, I suppose I should state my exact problem.
I'm using notepad++ as my LaTeX compiler and sending the final pdf to chrome. The reason: I usually have ~20 tabs open related to the project I'm working on and it just makes my work much easier to split my screen between notepad++ and chrome.
My current batch file compiles the LaTeX code and sends the compiled document to chrome as a new tab. For obvious reasons, i don't want to close a tab each time I compile, so I thought that closing the current tab at the same time during compiling would solve my problem. But, I just can't find a way to get my batch file to only close the tab with my compiled pdf.
Thanks in advance!
check all running chrome instances/tabs with :
wmic process where "caption='chrome.exe'" get
and see processes properties.Probably the best indicator that you can rely on in this case is CreationDate (other properties are basically the same for all chrome instances) - it always comes in format YYYYMMDDHHmmss.ms and is easy for string comparison.But you'll have to know the time when it was started.

How to Start ChromeDriver.exe without EULA with Selenium Webdriver? [duplicate]

I am learning to use Selenium (v2.20) to get ahead of some of our programmers who will soon be creating some browser tests with it. I'd like to uncover the pitfalls before they get there, and I've stumbled into one.
When I create my ChromeDriver, it always brings up a "Google Chrome EULA" and presents two buttons: "Accept and Run" and "Cancel". As I want this to be an automated test, having a user click a button is out of the question.
I looked at a list of Chromium Command Switches but did not find any that worked, nor any that mentioned EULA. The test works fine if I (at a breakpoint) click "Accept and Run" and then let the code continue.
The code, up to the line that causes the problem, is below:
using (var driverService = ChromeDriverService.CreateDefaultService(#"C:\Apps\ChromeDriver\"))
{
driverService.Start();
// This line pops up the EULA
IWebDriver driver = new ChromeDriver(#"C:\Apps\ChromeDriver\");
// rest of test...
}
Has anyone else run into this issue? If so, how did you solve it?
UPDATE 4/4/12
I just ran the same code on my computer at work and I succeed without triggering the EULA (consistent with Slanec's experience). This leads me to believe the cause is environmental. I'm looking into the differences between the two systems (both Win7 x64) to determine the cause. I'll update once I have more information.
Thanks much,
-Seth
In case you still have this problem, the error occurs because you are opening up a brand new instance of the chrome browser every time you run the test, thereby triggering the EULA. If you copy the default chrome profile into a custom location of your choice, and then add the "--user-data-dir=yourcustomlocation" flag to ChromeOptions, you can bypass the EULA and open up the existing profile instead.
ChromeOptions crOptions = new ChromeOptions();
crOptions.AddArgument(#"--user-data-dir=C:\custom location");
return new ChromDriver(crOptions);
Steps:
Copy your chromedriver.exe into Windows/System32
Now Go to your chrome folder, for me it is: C:\Users\"%USERNAME%"\AppData\Local\Google\Chrome\
There is a master_preferences file.
Open it and false EULA option.
It works for me, hope will work for you all also.

SublimeRope Autocompletions not working on Windows

I'm having trouble getting autocompletions to work for SublimeRope on Windows 8.
First, I noticed that SublimeRope messes up paths when creating a new Rope project on Windows, so I fixed the python_path prefs in .ropeproject > config.py, which are:
prefs.add('python_path', 'C:/Users/brandon/python_virtualenvs/aa/Lib/site-packages')
prefs.add('python_path', 'C:/Users/brandon/django_projects/andrews-app')
I've also tried specifying the packages to auto-import in my project file:
"rope_autoimport_modules": ["django.*"]
When I attempt to run: Rope: Regenerate Global Module Cache, I get an error:
"Missing modules in configuration file"
which Google has not been able to provide an answer for. Is anyone on Windows able to get SublimeRope working? I would really appreciate some help!
I documented how I kind of fixed it here:
https://github.com/JulianEberius/SublimeRope/issues/54
Basically, I added:
sys.path.insert(0, r"C:\Python27\Lib\site-packages")
in sublime_rope.py itself.
Obviously a hack, but it works until the code gets fixed upstream.