localhost refused to connect, after returning from paypal sandbox - google-chrome

Testing with PayPal checkout with Selenium & chrome webdriver.
I have tried using another domain name, localhost and 127.0.0.1
It may be important to note i am running inside a Vagrant machine (homestead)
Also tests run manually work.
I believe the issue to be an environment variable
PAYMENT_SANDBOX_PAYPAL_URL=http://localhost:8000/checkout/, however that is confusing as from what i understand there should be no difference when running automated tests with a webdriver.
Is this a networking issue with vagrant and my host? how would i diagnose this?
I understand this is a pretty specific question to the mentioned setup, however i think other new selenium users like myself will find it useful, especially when using codeception and laravel.
Perhaps it has something to do with whitelisting ip's?
Here is the current command.
java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalonjar -Dwebdriver.chrome.bin="/usr/bin/google-chrome" -Dwebdriver.chrome.driver="vendor/bin/chromedriver" -Dwebdriver.chrome.options="--whitelisted-ips=173.0.82.77,127.0.0.1"

I would guess chrome is running with different profile when launched manually (when it is able to load) and when launched through webdriver. WebDriver launches the browser in a different profile which may be very different than default profile which may include some settings related to proxy/networking.
From https://sites.google.com/a/chromium.org/chromedriver/capabilities
By default, ChromeDriver will create a new temporary profile for each session. At times you may want to set special preferences or just use a custom profile altogether. If the former, you can use the 'chrome.prefs' capability (described later below) to specify preferences that will be applied after Chrome starts. If the latter, you can use the user-data-dir Chrome command-line switch to tell Chrome which profile to use:
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");
You can create your own custom profile by just running Chrome (on the command-line or through ChromeDriver) with the user-data-dir switch set to some new directory. If the path doesn't exist, Chrome will create a new profile in the specified location. You can then modify the profile settings as desired, and ChromeDriver can use the profile in the future. Open chrome://version in the browser to see what profile Chrome is using.

Are you sure, that PayPal Sandbox URL should be a local URL, not accessible from outside of your box?
Please provide more details! What web framework/web server do you use? What are libraries you used to get PayPal working.
I think, if the behavior differ when running Selenium, it is an issue completely related to WebDriver settings, or it's work together with Vagrant.

Related

Chrome request not making it to server

I have a Windows 2016 Server with IIS 10.0.14393.0 installed that is maintained within an isolated VM environment. (The entire VM environment is isolated from the real-world.)
The web server is configured with three websites through IIS, and each website is assigned a dedicated IP. The contents in each of these websites is a single "hello world" html page that can be accessed via a browser from from my development workstation using Microsoft Edge, but I cannot access these pages using Chrome. The simple hello world html page was created only to assist in troubleshooting this issue.
The error received in Chrome is ERR_TIMED_OUT and based on the IIS logs, the request is never reaching the web server. IIS logs do indicate the request/reponse when accessing using Edge.
From my workstation, I can successfully ping the web server, traceroute output does not indicate any unexpected hops, etc. From all indications, the problem appears to be isolated to Chrome and only when accessing the sites on that server. I have other servers (W2016 and W2019) in the real-world with a similar configurations and real applications deployed there that work as expected with any browser.
I am using the latest Chrome Version 105.0.5195.102 (Official Build) (64-bit) and can access other web based content within this VM environment using Chrome, just not on that one server.
I am almost to the point of deleting that VM instance and starting over so any ideas/suggestions are appreciated.
The error received in Chrome is ERR_TIMED_OUT
This is a communication problem indication that there is a problem with the user's local network connection. It can appear when your internet is too slow or your connection is taking too long, or the page or website you are visiting may be too busy, or when the website in question is not set up correctly, or even if the website is trying to perform more than your server can manage.
I'm not sure if you've seen the following methods, but you can try.
Method 1: Browse in Incognito Mode and Remove Extensions.
You should first browse the website in incognito mode to check if you
can open the website normally, if so then the culprit of the
ERR_TIMED_OUT error may be your plugin or extension. Therefore, you
need to enable extensions one by one to check for errors, and if there
is an error enabling an extension, you need to remove it from your
browser.
Method 2: Delete the Default Chrome Folder
Press Win + R keys at the same time to open the Run
Type %LOCALAPPDATA%\Google\Chrome\User Data\ in the box and click OK.
Close your Chrome if it is opened.
A new window pops out, find the folder named Default. Backup the folder anywhere else, then right-click the folder to choose Delete.
After you have deleted the folder successfully, open your Chrome and
then visit the webpage again that you searched before to check if the
error still appears.
Method 3: Update Network Drivers
If your network driver is out of date, you may encounter ERR_TIMED_OUT
errors. Here's how to update network drivers.
Right-click the Start button to select Device Manager.
Scroll down to find Network Adapters and click on it to expand it.
Right-click on your network device and select Update Driver.
Select Search automatically for updated driver software option to start to search and update your network driver to a new version.
After that, restart your computer and open the sites again with Chrome
to see if you can open them.
Method 4: Disable Firewall & Antivirus Software
Sometimes, your firewall or antivirus software may cause trouble.
Therefore, you should try to disable them and check if the problem can
be solved. If you find it helpful to disable these programs, you can
check the firewall settings. Allow Chrome to connect to public or
private networks. If it doesn't work. Permanently delete these
programs, and then use other antivirus software or firewalls.
Method 5: Check Hosts File
When you meet the ERR_TIMED_OUT error accessing a specific website,
you can check the Hosts file to see if the website has been blocked.
Here is the way to do that:
Press Win + E keys at the same time to open File Explorer and then go to the Local Disk C: > Windows > System32 > Drivers > etc.
Open the host file with notepad. If you see the web address that you cannot visit, delete that entire line from the host file and save.
After that, open the Chrome and see if you can open the specific
website.
Method 6: Reinstall Chrome Browser
If none of the methods above fix the ERR_TIMED_OUT error, then you
should try reinstalling Chrome. Here is the tutorial:
Press Win + R keys at the same time to open the Run box, then type appwiz.cpl and click OK to open a new window.
Find Google Chrome in the list, and then right-click it to choose Uninstall.
After uninstalling Google Chrome successfully, you also need to delete its leftover files. Open the Run box again, then type %appdata%
and click OK to open a new window.
Find the Google folder and then right-click it to choose Delete.
Go to Google Chrome’s site to download the latest version of the browser, and then install it.
The above methods are from the web article. To avoid link being unavailable, I have also presented the details. I am not sure if the above methods can help you, but I hope you can solve the problem soon.

Headless Chrome fails under IIS but works on command line

I am wrapping headless chrome using the excellent ChromeHtmlToPDF library. This we are using to dynamically render PDFs from a website. This works locally under IIS express, and also works on the server when recompiled as a console app, so the technology works. However running under IIS, chrome always exits immediately and a error of "one or more parameters are invalid", is returned.
You can fix this by passing Chrome a custom user profile directory:
chrome.exe --user-data-dir="C:\NewChromeProfile" ...
This directory will be created by the account under which Chrome is running, and therefore the account will have the permissions it needs.
After many many hours looking into this I finally solved it by running it under my own user, the restricted IIS user, then comparing the activity logs generated by the excellent microsoft process monitor.
I tracked it down to file permissions on one directory: C:\Windows\System32\config\systemprofile\AppData\Local\Google\Chrome\User Data
The app pool user needs write + modify permissions to this directory. It's up to you if you feel this is an acceptable security risk; however for us it is, for now.
This is where headless chrome stores it's crashpad directory. No amount of parameter fiddling seems to be able to dissuade it of this. That seems to be a bug.
Hope this helps someone else, I couldn't find anything on this anywhere.

Selenium chrome windows authentication

I am automating a webapplication which uses windows authentication to sign-in.
I am using selenium specflow c# and running my tests on teamcity which uses grid in turn on the build agent.
However each of my row in Examples under scenario outline is testing with a different user.
We are using before scenario hook to create the Remote webdriver instance which is context injected to all the step bindings. However, at this point it is assuming that the user is the logged in user on the hub .
If I am using hub/grid, I am able to test with only one user login as the website takes the user credentials of the logged in user on the hub.
To work around this, we have used credentials embedded in the url. This happens in the Given step much after the hooks run.
While Chrome stopped the support for url credentials, how do I impersonate the users logging into the browser connected via remoteweb driver.
I have explored using process to create webdriver process and passing the credentials. I am not sure if this is the right way.
Or how do I make Chrome prompt for user credentials and stop auto logging as the hub user.
Because of this we are unable to upgrade the Chrome version.
I have explored so much but did not find a conclusive solution.
Regards,
Vijaya

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

A custom extension is not listed in extensions page in some computers

I have developed a Google Extension for which I created a Windows installer package. That installer writes the corresponding registry entries as explained in https://developer.chrome.com/extensions/external_extensions#registry
All that works well in some computers. So, after I run the installer package and then run Google Chrome, a little popup appears telling me to enable the extension. I answer “Yes” to that question and from that time on, the extension works as expected.
However, in some computers, with the same version of Chrome (53.0.2785.116 m), the installer writes the corresponding entries to the registry but when I run Chrome, nothing happens and the extension is not listed in the chrome://extensions/ page.
In such cases, I can connect to web store to install the extension manually. However, this extension launches an application because it implements Native Messaging. When I install the extension manually it works (the native messaging host application is launched and works) but when I close and re-open Chrome, the host application is not run. To run it, I need to manually disable and then re-enable the extension.
Very strange what happening. Can you help me on this please?
Based from this thread, (which is somewhat related to your issue), when you close the Chrome, it will fire onDisconnect event that's why the application is not running.
Native messaging means only Chrome can start a host instance when it "connects". It's a misnomer, since connect() means "launch a new copy and talk to it".
There is no way to "attach" to an already-running process. If you close the host, stdio pipe is broken the Port object fires onDisconnect event. Then you need to re-launch the host from the extension to be able to talk to it.
You can check on this link. Just make sure that no antivirus or firewall programs on your computer are causing the problem. If you can open Google Chrome when the firewall is off, you may need to create an exception in your antivirus or firewall settings.
However, in some computers, with the same version of Chrome (53.0.2785.116 m), the installer writes the corresponding entries to the registry but when I run Chrome, nothing happens and the extension is not listed in the chrome://extensions/ page.
You may be encountering blacklisting if that extension was ever installed, then uninstalled.
What if the user uninstalls the extension?
If the user uninstalls the extension through the UI, it will no longer
be installed or updated on each startup. In other words, the external
extension is blacklisted.
How do I get off the blacklist?
If the user uninstalls your extension, you should respect that
decision. However, if you (the developer) accidentally uninstalled
your extension through the UI, you can remove the blacklist tag by
installing the extension normally through the UI, and then
uninstalling it.