2014-11-20 5 views
1

나는 특히 아래의 클릭 후, ptor.sleep() 전화를 많이 사용하거나 전혀 사용하지 않으려하는 초보자입니다. 아래 라인은 다음에 ptor.sleep(1000); 콜을 포함하지 않는 한 결코 값을 얻지 못합니다 (모두 Nan을 반환합니다).각도기 클릭 동작은 ptor.sleep()을 사용합니다. 어떻게 올바르게 해결할 수 있습니까?

클릭 한 후 함수의 클릭을 래핑 한 후에 목록의 결과를 해결하기 위해 배열 elem을 만들기 위해 여러 시도를했지만 수면 호출 없이는 아무 것도 시도하지 않았습니다. 각도기 제어 흐름을 이미 읽었습니다. 나는 ptor.sleep() 호출을 제거 할 수 있도록 어떤 통찰력

devCountString = parseInt(arr[i]); 

덕분에, 어쩌면 내가 분명 뭔가 싶었어요.

내 스펙 : in the documentation를 같이 동작이 webdriver로 이동

describe('\n == patch List suite results == \n', function() { 

// login already was done in config files, onPrepare function. 
var ptor, noFilterCount; 

// needed here if we turn ptor.ignoreSynchronization = false; 

beforeEach(function() { 
    ptor = protractor.getInstance(); 
    ptor.ignoreSynchronization = true; 
    browser.get('https://my.abc.com:3000/fixes'); 
    ptor.sleep(1200); 
}); //end beforeEach() 

it('11 - verify filter fewer', function() { 

    var sevStringElm, sevString; 
    var applicableCount; 

    ptor.ignoreSynchronization = false; 
     ptor.sleep(500); 

    sevStringElm = element(by.css("input.form-control.bf-spinner")); 
     sevStringElm.clear(); 
     ptor.sleep(500); 

    sevStringElm.sendKeys('8'); 
     ptor.sleep(500); 

// click on the "fewer" spinner, wrap the click to wrap the . 
    var fewerPromise = element(by.css("span.bf-spinner-toggle:nth-child(2)")).click(); 
     ptor.sleep(1000); 

// now get the list of clickable elements in each device card. by title 
    var applicableDevicesElm = element.all(by.css("[title$='Applicable\ Devices']")); 
     applicableDevicesElm.getText().then(function(arr) { 
      console.log("arr.length= "+arr.length); 
      for (var i = 0; i < arr.length; i++) { 
       devCountString = parseInt(arr[i]); 
       expect(devCountString).toBeLessThan(9); 
      }; 
     }); 
    }); 

답변

0

매번, 각도기는 흐름 큐에 그것을 넣어 것입니다. 결과적으로 클릭 후 요소를 검사 할 때 대기열은 종속성을 해결하고 파인더에 대한 상태를 준비해야합니다. 어쨌든, 각도기가 동작 (항상 asyc)에 대해 암시 적으로 줄 바꿈을하지 않으려는 경우에도 클릭 후 .then(function(){})을 넣고 그 익명의 calback 기능에 포스트 클릭 논리를 넣을 수 있습니다. 더 이상 ptor을 사용해야합니다. 각도기 인스턴스 기능을 혼합하는 대신 browser을 사용하십시오. 예 : browser.sleep(1000)