Google Apps를 테스트하기 위해 UIAutomation을 사용하고 있습니다. 내가하고 싶은 일은 todayPicker의 임의의 날짜를 오늘 전날 (같은 해)에 선택하는 것입니다. 나는 무작위로 월과 일의 가치를 이미 얻었다. 나는 "월"예를 들어 한 달에 반환 않는 valueAtIndex
변수를 점검 한날짜 선택 도구의 selectValue가 작동하지 않습니다.
var currDate = new Date();
var year = currDate.getFullYear();
var month = new Array;
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var setMonthInt = currDate.getMonth();
var day = currDate.getDate();
var randomMonth = Math.floor((Math.random() * (setMonthInt + 1 - 0)) + 0);
var valueAtIndex = "\"" + month[randomMonth] + "\"";
if (randomMonth == setMonthInt){
var randomDay = "\"" + Math.floor((Math.random() * (day)) + 1) + "\"";
} else {
var randomDay = "\"" + Math.floor((Math.random() * (32)) + 1) + "\"";
}
this.window().popover().pickers()[0].wheels()[1].selectValue(valueAtIndex);
this.window().popover().pickers()[0].wheels()[0].selectValue(randomDay);
과 randomDay
변수는 "9"예를 들어, 하루를 반환하지 : 여기 내 코드입니다. - selectValue requires a valid value.
가 setValue()
방법 중 하나가 작동하지 않습니다
는 최대한 빨리이 selectValue()
방법 악기 사용으로 오류가 발생.
피커에게 무작위로 생성 된 임의의 월 및 일을 얻으려면 어떻게해야합니까?
나는이 줄이 'Math.floor (Math.random() * (32)) +1)' 이 가능한 날로 32를 반환 할 수 있다고 생각합니다. 32 * .99는 반올림 한 31 + 1은 32입니다. 그게 오류의 원인일까요? – Braains
@Braains 문제가 아니기 때문에 32는 반환 값으로 포함되지 않습니다. – user3253063