-
Notifications
You must be signed in to change notification settings - Fork 62
TypeError: Cannot read property 'browser_version' of undefined #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
After a long time debugging and narrowing down, I found that the following happens for getBrowserObject: function(entry) {
var browserObject = {};
var version = null;
var sliceStart = 1;
if (typeof entry === 'string') {
// …
if (browserData[lindex] && browserData[lindex].indexOf('+') === -1) {
if (['current', 'previous', 'latest'].indexOf(browserData[lindex]) !== -1) {
// …
} else {
version = browserData.slice(sliceStart, lindex + 1).join('.'); // <!-- assign "9"
}
} else {
// …
}
if (browserObject.mobile) {
// …
} else {
browserObject.browser_version = version; // <!-- assign "9"
}
} else {
// …
}
browserObject = ConfigParser.populateOsAndOsVersion(browserObject); // <!-- assign undefined
return browserObject;
} populateOsAndOsVersion: function(browserObject) {
if (!(browserObject.os && browserObject.os_version)) {
if (browserObject.mobile) {
// …
} else {
// …;
var osxFiltered = ConfigParser.bsBrowsers.filter(function(currentValue) {
return currentValue.os === 'OS X' && currentValue.browser === browserObject.browser && ((browserObject.browser_version && browserObject.browser_version.indexOf('latest')) > -1 || parseFloat(currentValue.browser_version).toPrecision(4) === parseFloat(browserObject.browser_version).toPrecision(4));
});
// ^ osxFiltered is []
var filteredObject = osxFiltered[Math.floor(Math.random() * osxFiltered.length)];
// ^ filteredObject ==> osxFiltered[0] ==> undefined
browserObject = filteredObject;
}
}
return browserObject;
} I thought that |
When no match is found, the process would just crash. Instead, recognise this as a normal end-user scenario and point them to the list of available workers. In my experience the most common way to encounter this issue is when additional decimal places are required by the API, e.g. "safari" "9" results in a crash, because the available workers are described as "9.1" instead. Given that most browers are described without a decimal place, this is an easy mistake to make. Another way to get this is when there is a misspelled browser name. Before: ``` TypeError: Cannot read property 'browser_version' of undefined at browserstack-runner/bin/cli.js ``` After: ``` Error: No desktop match found for {"browser":"safari","browser_version":"9"} Check https://www.browserstack.com/list-of-browsers-and-platforms/js_testing at populateOsAndOsVersion (browserstack-runner/lib/configParser.js) ``` Fixes browserstack#243.
Expected Behavior
Test against
firefox_45
,safari_9
,safari_10
,safari_11
.Actual Behavior
browserstack.json
Platform details
0.9.4
The text was updated successfully, but these errors were encountered: