2012-02-11 2 views
0

아이폰 용 UITesting을 시험 중이고 스탠포드의 cs193p iTunes U 클래스 강의 2에서 간단한 테스트 도구를 사용하여 첫 번째 테스트를 수행 할 것이라고 생각했습니다. 스크립트가 죄를 실행하지만iphone UITesting 숫자 인

var target = UIATarget.localTarget(); 

target.frontMostApp().mainWindow().buttons()["3"].tap(); 
target.frontMostApp().mainWindow().buttons()["Enter"].tap(); 
target.frontMostApp().mainWindow().buttons()["4"].tap(); 
target.frontMostApp().mainWindow().buttons()["/"].tap(); 

var display = target.frontMostApp().mainWindow().staticTexts()[1].value(); 
if (display == "0.75") { 
    UIALogger.logPass("3 E 4 /"); 
} else { 
    UIALogger.logFail("3 E 4 /"); 
} 

다음과 같이

내 자바 스크립트는 편집기에서 COS/ 는 그래서 어떻게 든 악기를

target.frontMostApp().mainWindow().buttons()[3].tap(); 
target.frontMostApp().mainWindow().buttons()["Enter"].tap(); 
target.frontMostApp().mainWindow().buttons()[4].tap(); 
target.frontMostApp().mainWindow().buttons()["/"].tap(); 

을 보여주는 로그로 내 문자열 "3"으로 변환되어 입력 색인 3을 누른 다음 세 번째 버튼을 누릅니다.

그래서 인덱스 번호로 단추를 호출 할 수 있지만 텍스트로 호출하는 것이 좋습니다.

답변

1

대괄호를 사용하여 UIAElementArray의 해당 숫자에 인덱스로 처리되는 것은 한계가 있습니다. . 8 (

대신 단지 firstWithName() 추가

target.frontMostApp().mainWindow().buttons().firstWithName("3").tap(); 

참조 UIAElementArray Class Reference

관련 문제