문제

내가 사용하여 NightwatchJS 와 라이브러리에 해당하는 개발용: http://nightwatchjs.org/api

나는 모달을 대화할 수있는,또는 나타나지 않을 수도 있습니다.그 #close_button 될 필요가 있는 클릭(경우에는 모달 나타나지 않는다)를 계속합니다.

abortOnFailure 의 매개변수 waitForElementPresent 하기 false 그래서 스크립트를 계속 경우에는 모달이 나타나지 않습니다.그러나 나는 그것을 얻을 수 없습니다.

어떤 방법이 있나요?

module.exports = {
    "Test" : function (browser) {
        browser
            .url("http://domain.com/")
            .waitForElementPresent('#close_button', 5000, false, function() {
                this.click('#close_button')
            })
            .setValue('#username', 'test@email.com')
            //more code here
            .end(); //does end() go here or inside .waitForElementPresent() above?
    }
}
도움이 되었습니까?

해결책

abortOnFailure 작동,그러나이 waitForElementPresent 버그가 있는 지금에는 콜백을 통과의 정확한 맥락에서.는 해결 될 것입니다.

평균 시간에 당신의 테스트는 다음과 같이 배치 click 밖에는 동일한 것과 보이는 청소기:

module.exports = {
  "Test" : function (browser) {
    browser
      .url("http://domain.com/")
      .waitForElementPresent('#close_button', 5000, false)
      .click('#close_button')
      .setValue('#username', 'test@email.com')
      //more code here
      .end(); // end() goes here
  }
}

다른 팁

내가 달렸으로가 기다리고 있었 iframe 을 수 있습니다.내가 만들어하는 기능을 실제로 그것을 닫:

pageObject 기능:

Home.prototype.closeIframe = function(browser) {
var self = this;
console.log('Checking for iframe');
this.browser
        .isVisible(iframeSelectors.iframe, function(result) {
            if (result.value === true) {
                self.browser
                        .log('iframe visible')
                        .frame(iframeSelectors.name)
                        .waitForElementVisible(iframeSelectors.closeLink)
                        .click(iframeSelectors.closeLink)
                        .assert.elementNotPresent(iframeSelectors.iframe)
                        .frame(null)
                        .pause(2000); //allow for proper frame switching
            } else {
                console.log('iframe is not visible');
            }
        });

return this;

에서 제공하는 테스트를 기다리 페이지를 완벽하게 부하를 실행하기 전에 위의 기능입니다.

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