Using headless chrome number format is messed up - selenium-chromedriver

I am using headless chrome. Most of the test cases do pass with this change.
But wherever any number assertions are there, they are failing, which is nearly 100 tests out of 800 tests.
Ex:
The following asserts failed: Incorrect promotion percentage Expected: "15%" but: was "0.150000000000000" Amount is incorrect Expected: "-1000.00 USD" but: was "-1000.000000000000000 USD"
Is there any central place where I can change the setting and these number formatting issue can be resolved. Or should I update each test case. Using java 8, selenium web driver, chromedriver 2.40

I got the similar problem. I resolved this by setting the locale through command line option for headless chrome browser as follows. It looks like in headless mode, chrome browser hasn't been set with any locale but these formatters have a dependency over locale. Hence the problem. I passed the locale to chrome options
chrome.switches=--headless,--window-size=1920,1080,--lang=en

Related

setDownloadBehavior analog for Firefox at Puppeteer

For chromium, in Puppeteer it is possible to block file downloads using the cdp command Page.setDownloadBehavior. Is there something similar for Firefox? Otherwise, it downloads all files automatically :(
Of course, I tried using Page.setDownloadBehavior for Firefox as well, but it throws an error:
Protocol error (Page.setDownloadBehavior): Page.setDownloadBehavior RemoteAgentError#chrome://remote/content/cdp/Error.jsm:29:5\nUnknownMethodError#chrome://remote/content/cdp/Error.jsm:112:7\nexecute#chrome://remote/content/cdp/domains/DomainCache.jsm:98:13\nreceiveMessage#chrome://remote/content/cdp/sessions/ContentProcessSession.jsm:84:45\n
I found a list of CDP support in Firefox and there is nothing there that could be somehow similar to what I need. Page.setDownloadBehavior, apparently, is only in the plans.

Asp.net core Chrome Issue with Cookies

I have a strange issue, we are running a asp.net core razor app.
There are no issues logging into Firefox or Edge.
But rather randomly, we have an issue in Chrome that we can't figure out.
(Random as in, it has occurred on user's machines randomly before and now it is occurring on a lot of machines, but still not all of them)
The issue is that it seems that our "auth-token" cookie is not being set.
To me, it seems that the error is with this line which runs after a successful username and password, but before a redirect.
...
Response.Cookies.Append("auth-token", inToken, option);
...
There is no error, but a line that runs almost immediately after falls over
public async Task Invoke(HttpContext context)
{
var name = "auth-token";
var cookie = context.Request.Cookies[name]; //THIS LINE DOESN'T HAVE THE COOKIE CALLED "auth-token" IN CHROME
...
}
We have tried:
Incognito Chrome/Clearing Cache/Cookies in Chrome
Restarting Machine
Uninstalling and Reinstalling chrome
Installing old versions of Chrome (chromium)
Running an old version of our code (which previously worked on chrome)
There doesn't seem to be a clear cause for when this issue occurs.
I would love to figure out why this is happening or if possible any information on how I could capture what is happening.
Thank you!
After many hours researching it seems I have finally fixed my issue.
By setting the following in our cookie
SameSite = SameSiteMode.Lax
or
SameSite = SameSiteMode.Strict
Our Chrome issues have been fixed
I was reading about Google Chrome's "SameSite" cookie options.
https://www.chromium.org/updates/same-site
Originally I thought this was unrelated as SameSite has been forced in Chrome for quite a wile now, and it has never bothered our code. But I still tried setting:
SameSite = SameSiteMode.None
To no changes
After bringing this up to my boss he informed me that he noticed an old warning that appeared in the chrome console for <1 second.
'A cookie associated with a resource at ... was set with
'SameSite=None' but without 'Secure'. It has been blocked....'
(Note: This was before I tried messing around with SameSite Options at all and was part of some code to fix a Safari bug)
So naturally we managed to capture the error with a quick screenshot and then we added in the SameSite option with Strict.
So I while it works for me now it still doesn't explain;
Why didn't it break earlier, we have been using versions of chrome with it for several months
Why does it still not break if I run an old version of the code with .net 2.1 (without any SameSite Options adjusted)
Why does our new version of the code without the adjusted SameSite option still work on some user's machines

Chrome 58 Not secure Data in URL

The recent upgrade to Chrome 58 has caused an issue. When Selenium launches an instance of Chrome it doesn't navigate to the initial URL like it did with Chrome 57. Now when Chrome is launched via Selenium we get this issue:
It just hangs right there and won't move. Has anyone else found a workaround for this?
If I downgrade back to Chrome 57... no issues what-so-ever! Unfortunately we need to use 58 now.
I have several nodes in my grid and this occurs on every single one of them. I thought maybe it was a group policy or something but the fact that it runs perfectly on 57 makes no sense to me.
** Update: another issue that I'm having is that it often takes two or three attempts at opening the browser before it finally launches.
Add the --enable-automation argument to your webdriver. By default, Chrome 58 requires https and it will not display pages that cannot handle this, the enable-automation lets the browser know the webdriver is steering and it is safe to display the page.

GeoLocation from gpsd

The gpsd program lets linux users cleanly organize their GPS peripheral data, such that a command line program like cgps or a graphical one like xgps can read the data, and write to a socket, like /var/run/gpsd.sock.
There's a nice tutorial on the net for rigging a raspberry pi to use this data. This is all well and good, but how can I integrate this data in firefox or chromium, as the geolocation API? Is there a specific build process I might need? For instance, setting a ./configure flag or something? Is there a way to integrate this data in a prebuilt version of either browser?
Firefox on Linux supports gpsd - it was added in Firefox 4, removed in Firefox 23 and added back in Firefox 50.
However, it still needs to be enabled during build, with --enable-gpsd (which seems not to be the case yet in Ubuntu) and in the configuration, by following these steps:
Navigate to about:config
Create a new string preference, name geo.location.use_gpsd value true
Prior to Firefox 23, you had to:
Create a new string preference, name geo.gpsd.host.ipaddr value localhost
Create a new boolean value, name geo.gpsd.logging.enabled value true
Google Chrome had gpds support added in November 2011 and removed in October 2013. It looks like hardware GPS support is not a priority. If this was handled in Chrome OS, it might be possible to use the same mechanism, but I don't see support there either.
Someone built an extension which attempts to provide support in recent versions, requiring to install a script system-side.
Firefox on linux used to support gpsd.
Navigate to about:config
Create a new string preference, name geo.gpsd.host.ipaddr value localhost
Create a new boolean value, name geo.gpsd.logging.enabled value true
However, it seems that the gpsd support has been removed
Chromium seems to have had gpsd support in the past, but I can't find anything about it now. It looks like hardware gps support is not a priority. If this was handled in ChromeOS, it might be possible to use the same mechanism, but I don't see support there either.
In both cases, it should be possible to write an extension to fake the GPS coordinates, which could read from your real GPS.

Selenium IDE doesn't open webpages that return a json response

I have a big Selenium test suite that's testing a web service. Given an input url, the web service returns either a regular html response or a json response. The test suite is being executed with Firefox's Selenium IDE. The tests call the open command on a given url and then verify stuff on the returned json/html. It used to work great until for some reason Firefox has stopped opening the jsons automatically. Instead of opening the json response as if it were a regular web page, Firefox asks "What should Firefox do with this file" and prompts me to select a program to open the file with.
How do I force Selenium IDE to make Firefox display the json responses as it used to?
Cases like these are usually Firefox & Selenium IDE version incompatibility. This can be from using a much newer version or an old version of Firefox that the IDE doesn't quite support.
In your case it appears to be an older version issue.
The first step you should do is update both the IDE & Firefox and take it from there.
The release notes also detail what version (range) of Firefox it generally supports.