mirror of
https://github.com/appium/appium.git
synced 2026-04-27 13:59:33 -05:00
Merge pull request #3329 from imurchie/isaac-caps
Handle boolean caps sent as strings
This commit is contained in:
@@ -97,6 +97,16 @@ Capabilities.prototype.setDesired = function (caps) {
|
||||
JSON.stringify(value));
|
||||
caps[cap] = JSON.stringify(value);
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
// handle the case where users send in "true" or "false" as a string
|
||||
// instead of a boolean
|
||||
var tempValue = value.trim().toLowerCase();
|
||||
if (tempValue === "false" || tempValue === "true") {
|
||||
logger.warn("Converting cap " + cap + " from string to boolean. " +
|
||||
"This might cause unexpected behavior.");
|
||||
caps[cap] = (tempValue === "true");
|
||||
}
|
||||
}
|
||||
});
|
||||
_.each(caps, function (value, cap) {
|
||||
if (_.contains(_.keys(capsConversion), cap)) {
|
||||
|
||||
@@ -22,6 +22,18 @@ describe('capabilities', function () {
|
||||
c.platformVersion.should.equal(7.0);
|
||||
(typeof c.platformVersion).should.equal("number");
|
||||
});
|
||||
it('should convert string booleans into actual booleans', function () {
|
||||
var c = new Capabilities({
|
||||
stringFalseCap: "false",
|
||||
stringTrueCap: "true",
|
||||
realFalseCap: false,
|
||||
realTrueCap: true
|
||||
});
|
||||
c.stringFalseCap.should.equal(false);
|
||||
c.stringTrueCap.should.equal(true);
|
||||
c.realFalseCap.should.equal(false);
|
||||
c.realTrueCap.should.equal(true);
|
||||
});
|
||||
describe('with mjsonwp capabilities', function () {
|
||||
describe('deprecation warnings', function () {
|
||||
var newCapabilities = [
|
||||
|
||||
Reference in New Issue
Block a user