문제

    @Before public void setUp() {
        Robot robot = BasicRobot.robotWithCurrentAwtHierarchy();
        ApplicationLauncher.application("myApp").start(); 

        Pause.pause(5, TimeUnit.SECONDS); 
        frame = WindowFinder.findFrame("frame0").using(robot);

        JTableFixture table = frame.table(new GenericTypeMatcher<JTable>(JTable.class) {
             @Override protected boolean isMatching(JTable table) {
                return (table instanceof myTreeTable); 
             }  
        });
    }
.

이 코드는 잘 작동합니다.5 초 후 일시 중지를 제거하면 앱에 몇 초가 걸리지 않기 때문에 테이블을 찾을 수 없습니다.

나는 그것을 깨끗한 방법이 있는지 알고 싶습니다.robot.waitforidle () applicationLauncher (EDT가 비어있는 것 같아요, 모든 것이로드되는 것 같지만, 방금 작동하지 않습니다.

나는 일시 중지가 멈출 때 어떤 이벤트로 약간의 조건을 사용할 수 있지만 Javadoc 및 공식 문서가 가난한 이후로 작성하는 방법을 이해하지 못합니다.

  • pause.pause (waitforcomponentToshowcondition.untilisshowning (frame.component ())) : 작동하지 않는 래퍼 프레임을 통과하면 구성 요소가 필요합니다.그리고 나는 그것이 정확하게 내가 얻기 위해 기다리고있는 것 때문에 나는 테이블을 통과 할 수 없다.
  • 나는 그것을 이해할 것입니다. 나는 아마 componentFoundcondition과 함께 일해야하지만 나는 그것을 얻지 못한다!나는 피곤하다 :

           ComponentMatcher matcher = new GenericTypeMatcher<JTable>(JTable.class) {
               @Override protected boolean isMatching(JTable table) {
                 return (table instanceof myTreeTable); 
               }  
           };
    
           Pause.pause(new ComponentFoundCondition("DebugMsg", frame.robot.finder(), matcher)); 
    

    도움말

도움이 되었습니까?

해결책

componentFinder 를 찾을 수 있습니다.구성 요소.예를 들어, 그 질문에있는 Matcher를 기반으로합니다.

final ComponentMatcher matcher = new TypeMatcher(myTreeTable.class);

Pause.pause(new Condition("Waiting for myTreeTable") {
    @Override
    public boolean test() {
        Collection<Component> list = 
                window.robot.finder().findAll(window.target, matcher);
        return list.size() > 0;
    }
 }, 5000); 
.

여기에 이름별로 조회를 사용하는 대안이 있습니다.

final ComponentMatcher nameMatcher = new ComponentMatcher(){
    @Override
    public boolean matches(Component c) {
        return "ComponentName".equals(c.getName()) && c.isShowing();
    }
};

Pause.pause(new Condition("Waiting") {
    @Override
    public boolean test() {
        Collection<Component> list = 
                window.robot.finder().findAll(window.target, nameMatcher);
        return list.size() > 0;
    }
 }, 5000);
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top