I have the below .json file and I just want to change the down and up values based on user input.
"android": {
"appium:autoAcceptAlerts": true,
"appium:automationName": "UiAutomator2",
"appium:newCommandTimeout": 180,
"appium:appPackage": "com.android.settings",
"appium:platformName": "android",
"appium:capture.networkConfig": {
"shaping": {
"down":5,
"up": 2
}
}
},
The above json body I'm trying to change the "down" attribute from "5" to "2" and "up" attribute from "2" to "1" by using the below code.
if(state == 'high')
{
let tempVal = caps[platform]; // let platform = 'android'
console.log("**********************");
console.log(tempVal); // It's printing the json body.
for(let prep in tempVal)
{
tempVal[prep].shaping.down = 2; //Not replaced.
tempVa[prep].shaping.up = 1; //Not replaced.
console.log(tempVal[prep].shaping.down); // It's not printing down and returned as undefined.
}
console.log("**********************")
}
CodePudding user response:
if(state == 'high')
{
let tempVal = caps[platform]; // let platform = 'android'
console.log("**********************");
console.log(tempVal); // It's printing the json body.
let prep = 'appium:capture.networkConfig';
tempVal[prep].shaping.down = 2;
tempVa[prep].shaping.up = 1;
console.log(tempVal[prep].shaping.down);
console.log("**********************")
}