Forcing proxy when running chrome over command line? - google-chrome

I'm trying to run headless e2e tests with chrome and selenium. But having issues getting chrome to adhere to a proxy server. When just trying to get chrome to use a proxy server as per the documentation, it gets completely ignored.
Is there anything obviously wrong with these configurations?
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --proxy-server='p-uk1.biscience.com:80'
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --proxy-server='http=p-uk1.biscience.com:80;https=p-uk1.biscience.com:80'
In each instance, by either checking a 'what is my ip' style website I get my usual IP. And when checking chrome://net-internals/#proxy the connection continues to show a DIRECT configuration.
Using a mac, but exact same issue when trying same configuration on my 14.04 ubuntu box :(

Related

Chrome is not logging SSL KEY in Ubuntu 20.04 LTS

I'm trying to decrypt HTTPS using Wireshark on Ubuntu 20.04.
I use this guide.
Basically:
You install Wireshark
You add SSLKEYLOGFILE environment variable
You open Chrome and visit the HTTPS site
You import the ssl key log file into Wireshark
And it decrypts the traffic
But no matter what I do, my .ssl-key.log file is empty. I closed Chrome and reopened it. Visited https://google.com and nothing is written in that file. I even restarted my laptop.
And these questions did not solve my problem:
Chrome not Firefox are not dumping to SSLKEYLOGFILE variable
SSLKEYLOGFILE environment variable doesn't populate any text file
I use chrome(Version 97.0.4692.99 (Official Build) (64-bit)) is worked.
you should run killall chrome to kill all chrome background instance.
then rerun google-chrome is work.
OR
user fiddler decrypt HTTPS,
https://docs.telerik.com/fiddler/configure-fiddler/tasks/decrypthttps
Decrypt HTTPS traffic with Wireshark and Fiddler
https://www.hhutzler.de/blog/decrypt-https-traffic-wireshark-fiddler/
The problem may be that Google Chrome doesn't have access to your user environment.
To resolve this,
launch google-chrome directly from a user terminal whenever you want to decrypt new traffic
or make a psueo-google-chrome launcher that points to the real google-chrome after setting the SSLKEYLOGFILE env variable

How to run Chromedriver in Java Selenium in BOTH headless and incognito?

The problem I am trying to solve is to login into a site that has SSO. I will need to login with different credentials at times so I don't want to SSO in. Therefore, I will open up an incognito tab in Chrome so the SSO login popup will show up every time: chromeOptions.addArguments("incognito"); This works fine when I am running not in a headless mode and using Java Robot to input the credentials.
However, when I run this in headless mode: chromeOptions.addArguments("headless"); I am back to square one where I got SSO'd in into my personal account without the manual control of inputting in different credentials. That's not what's happening when I have incognito in non-headless mode.
How exactly do I configure my Chromedriver through Java to be BOTH headless and incognito?
I need headless mode because I need to run this inside a Docker container.

Select client certificate for authorization in Chrome headless mode

I'm trying to run tests in headless Chrome using Geb. Before enter the page, I have to select client certificate for authentication. How to do this in headless mode?
Robot class not working without UI.
Is there any way to handle certificate selection? I read about policies and AutoSelectCertificateForUrls but I can't find way to load policy from file or set this particular parameter as option/argument (Chrome on Linux).
In PhantomJS there is option to provide certificate as argument but how to do this using Chrome driver?
I had the same problem and ended up running in headful mode instead. There are some stuff required to be installed on the server though to be able to run Selenium in headful mode. I wrote an article on the subject using Selenium with .NET Core in linux with environment setup through docker.
https://sgedda.medium.com/running-selenium-with-chromedriver-together-with-client-certificate-set-in-headful-mode-with-net-a79bde19e472
Dockerfile
https://gist.githubusercontent.com/sgedda/584aa35a0d9162ad24f9cca836266959/raw/1fc0b4e6e8c76b791437bc847b67b2ed676c5d9b/Dockerfile

How to get Chrome headless to autofill username / passwords?

How can I get Chrome launched in headless mode to autofill any stored username and passwords?
Launched normally from the command line, autofill works as expected. But with the --headless option, autofill does not seem to be happening (for the same pages & fields). I'm using the Chrome DevTools Protocol to remotely control the browser in both cases.
I am specifying a --user-data-dir that is the same in both "headed" and headless cases.
Version info: Google Chrome 62.0.3202.94 on Ubuntu 16.04.3 LTS

Using getUserMedia() on insecure origins in Chrome

I am developing a webpage that uses camera. When I test in Chrome in my local network, camera doesn't work and I get warning in the console:
getUserMedia() no longer works on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See link for more details.
In the link provided there is an instruction to set some flags in Chrome. So I tried. My command looks like this:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --unsafely-treat-insecure-origin-as-secure="192.168.0.15" --user-data-dir=c:\chrome-dev-profile
But when I run Chrome I get this message:
You are using an unsupported command-line flag: --unsafely-treat-insecure-origin-as-secure. Stability and security will suffer.
What am I doing wrong?
Is there another way I can test in local network without setting up https server? I need this just for development.
Luka,
I've run into this bug just yesterday. I have not found out how to get Chrome to honor that flag on the command line yet. But I did find a workaround that works for my case.
I'm running my web services on a Linux machine that is running an ssh server. I'm testing on windows with chrome, and used putty to connect to the linux box from windows and then created a "local port forward" to make my remote linux box's ipaddress:port appear on localhost:port on windows. Depending on your platform this workaround may work for you. This approach isn't too cumbersome if you only have a few ports to forward.
In my particular case my setting for putty looked like
L8080 localhost:8080
To see more about port forwarding and ssh see: https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding