2017-10-31 12 views
0

ページオブジェクトを見つけることができません。ここで何が欠けていますか? MyLegacyPage.jsNightwatch Page Object

module.exports = { 
    myPauseMethod: function (browser) { 
    browser.pause(1000); 
    return this; 
    } 
}; 
において

夜警0.9.16

nightwatch.jsonで

"page_objects_path": "pages", 
実際のフォルダで

\pages\MyLegacyPage.js 

試験で

describe('CTA', function() { 
    it('page objects tests', function (browser) { 
     console.log('browser.page.MyLegacyPage() = ' + JSON.stringify(browser.page.MyLegacyPage())); 
     var myPageObject = browser.page.MyLegacyPage(); 
     myPageObject.myPauseMethod(browser); 
    }); 
}); 

browser.page.MyLegacyPage() = {} 
TypeError: myPageObject.myPauseMethod is not a function 

答えて

1

はたぶん、POMのこの例では、あなたの問題解決に役立つかもしれない出力:

var dashCommands = { 

    uploadAvatar:function(){ 
     return this.waitForElementVisible('@profileIcon', TIMEOUT) 
      .click('@profileIcon') 
      .waitForElementVisible('@avatarUpload', TIMEOUT) 
      .moveToElement('@avatarUpload', 0,0) 
      .click('@avatarUpload') 
      .waitForElementVisible('@profileImageUploadOverlay', TIMEOUT) 
      .assert.visible('@closeButton') 
      .click('@selectPicture') 

    } 


module.exports = { 
    commands:[dashCommands], 
    elements: { 
     dashLogo : { selector: 'div.topbar__title-wrap.topbar-title > h1'}, 
     profileAvatar: { selector: 'span:nth-child(4) > div > img'}, 
     searchField: { selector: 'div.topbar__search-feald-wrap > input'}, 
     topicsColumn: { selector: 'div.inner-dashboard-wrap.topic-wrap'}, 
     conclusionsColumn: { selector: 'div.inner-dashboard-wrap.conclusion-wrap'}, 
     messagesColumn: { selector: 'div.inner-dashboard-wrap.messages-wrap'}, 
     bookmarksColumn: { selector: 'div.inner-dashboard-wrap.request-wrap'}, 
     profileIcon: { selector: 'span:nth-child(4) > div'}, 
     avatarUpload: {selector: '//*[@id="profile-section"]/div[1]/div[1]/img', locateStrategy: 'xpath' }, 
     selectPicture: { selector: '#dialogContent_profile-image-modal'}, 
     profileImageUploadOverlay: { selector: '.layout-column button'}, 
     closeButton: { selector: '.ng-scope.icon-close'} 
     }, 
} 

あなたはVARの内側にあなたの関数を作成しなければならないことを意味次に、module.exports部分に次のコード行を挿入してコマンドを挿入する必要があります。コマンド:[nameOfYourVar]

+0

ありがとう、私は拡張オブジェクトに変更し、それは働いた。ページオブジェクトを出力する際に​​、「{}」を表示するか、「それは循環構造」のエラーを表示するのが普通です –

関連する問題