2016-07-19 2 views
0

일부 테스트를 작성하기 위해 Cucumber와 함께 각도기를 사용하고 있지만 일부 지점에서 멈추었습니다. 로그인 후 단계에서 분도기에서 제공하는 browser.get (url) 함수를 사용하여 다른 페이지로 경로를 변경합니다. 그러나 페이지가 완전히로드되기 전에 항상 반환됩니다. 나는 많은 해결책을 지금까지 시도했지만 행운이 없다. 나는 browser.wait, browser.get (url) .then (function() {//로드 할 때 코드})로 시도했지만, 0은 긍정적 인 결과를 얻는다. 주변의 모든 제안 작업이 훨씬 이해 될 것이다브라우저를 사용하여 주어진 URL이 완전히로드되기 전에 반환합니다.

// Steps will be implemented here 
    this.Given(/^I am logged in as user \'([^\']*)\'$/, function (user, callback) { 
    console.log('USER: ' + user); 
    browser.driver.get('https://cit-was70-l06/ipa') 
    browser.driver.findElement(by.xpath('my_xpath')).sendKeys(user); 
    browser.driver.findElement(by.xpath('my_xpath')).sendKeys(user); 
    browser.driver.findElement(by.xpath('my_xpath')).click().then(callback); 
    }); 

    this.Then(/^The screen is shown, with title \'([^\']*)\'$/, function (title, callback) { 
    console.log('Title from feature file: ' + title); 
    var url = 'some/url/in/application/'; 
    browser.get(url).then(function(){ 
     // This portion executes before page is completely loaded. 
     // So if I try to get any element, it throws me an error. 
     // [15:32:13] E/launcher - "process.on('uncaughtException'" error, see 
     // launcher 
     // [15:32:13] E/launcher - Process exited with error code 199 
     // It works if I add static delay to wait for page load completely 
     // but that will not be a good solution if I have too much pages to test 
     callback(); 
    }); 
    console.log('After page laoad'); 
    }); 

:

여기 내 코드입니다.

+0

관련 항목 : [각도기 실행 후 uncaughtException] (http://stackoverflow.com/questions/38397965/uncaughtexception-after-a-protractor-run). – alecxe

답변

2
[15:32:13] E/launcher - "process.on('uncaughtException'" error, see launcher 
    [15:32:13] E/launcher - Process exited with error code 199 

위의 오류는 대부분 약속과 관련된 여러 가지 이유로 인해 발생할 수 있습니다. 그러나 올바른 메시지를 던져야합니다. 정확한 오류 메시지를 수신하려면 여기 https://github.com/angular/protractor/issues/3384에서 이미 해결 된 문제가 있습니다.

위의 포럼에서 언급 한대로 protractor 종속성의 파일을 launcher.ts으로 변경하면 문제를 디버깅하기 위해 inorder 오류를 잡을 수 있습니다.

protractor-cucumber에 단계 정의를 쓸 때 callbacks 대신에 약속이 return 인 것이 좋습니다. 이렇게하면 오이가 비동기 작업을 완료해야하는 시점을 알 수 있습니다.

+0

이 파일을 어디에서 찾을 수 있습니까 ??? –

+0

lib 디렉토리가 없습니다 –

+0

다음 경로 릴리스를 위해 수정되고 예정되어 있습니다.'launcher.js' 파일을 변경해야합니다. 자세한 내용은 여기를 참조하십시오. http://stackoverflow.com/questions/38397965/uncaughtexception - 이후 - 각도기 - 실행 –

0

아래 코드를 사용해보십시오. 도움이되는지 확인하십시오.

browser.get(url); 
browser.waitForAngular(); 
then try to call your function. 
0

사용 protractor.ExpectedConditions는 성공적으로 로그인 한 후 표시되는 페이지에있는 모든 요소의 가시성을 확인합니다. 아래와 같이 사용자 정의 된 메소드를 작성하십시오.

요소가 표시된 경우 browser.get();을 사용하여 다른 페이지를 탐색합니다.

Code Snippet 

EC = protractor.ExpectedConditions; 
//targetElement=element(locator); 
this.isElementVisible = function (targetElement, timeOut) { 
    'use strict'; 
    timeOut = timeOut !== undefined ? timeOut : 8000; 
    browser.wait(EC.visibilityOf(targetElement), 
     timeOut).thenCatch(function() 
     { 
     assert.fail(' element is not visible'); 
     }); 
};