2016-07-09 6 views
1

GebWATIRには、ページクラスで指定したpage_urlにアクセスするために使用するキーワードがあります。例えば。 toキーワードはGebvisitキーワードはWATIRです。ページオブジェクト:nightwatch.jsの<page_url>をご覧ください

nightwatch.jsで使用できる類似点私のようにそれを使用していますページクラスでは

module.exports = { 
    url: function() { 
     return this.api.globals.launchUrl + "/goto/desiredPage.html"; 
    }, 
    commands: [pageCommands], 
    elements: {} 
}; 

::私は試してみました

desiredPage 
      .url() 
      .foo() 
      .bar(); 
client.end(); 

が、それは誤り.url is not a functionを与えているこれは、私が試してみましたが、それは誤りを与えるものです。

答えて

0

あなたは、例えばナイトウォッチフォルダ内のナイトウォッチの例を参照することができますテストで

[page-objects/home.js] 
var searchCommands = { 
    submit: function() { 
    this.waitForElementVisible('@submitButton', 3000) 
     .click('@submitButton') 
     .api.pause(1000); 
    return this; // Return page object for chaining 
    } 
}; 

module.exports = { 
    url: 'http://google.com', 
    commands: [searchCommands], 
    elements: { 
    searchBar: { selector: 'input[name=q]' }, 
    submitButton: { selector: 'button[type=submit]' } 
    } 
}; 

、その後を:

/* jshint expr: true */ 
module.exports = { 
    'Demo Google search test using page objects' : function (client) { 
    var homePage = client.page.home(); 
    homePage.navigate(); 
    homePage.expect.element('@searchBar').to.be.enabled; 

    homePage 
     .setValue('@searchBar', 'Nightwatch.js') 
     .submit(); 

    var resultsPage = client.page.searchResults(); 
    resultsPage.expect.element('@results').to.be.present.after(2000); 
    resultsPage.expect.element('@results').to.contain.text('Nightwatch.js'); 
    resultsPage.expect.section('@menu').to.be.visible; 

    var menuSection = resultsPage.section.menu; 
    menuSection.expect.element('@web').to.be.visible; 
    menuSection.expect.element('@video').to.be.visible; 
    menuSection.expect.element('@images').to.be.visible; 
    menuSection.expect.element('@shopping').to.be.visible; 

    menuSection.productIsSelected('@web', function(result) { 
     this.assert.ok(result, 'Web results are shown by default on search results page'); 
    }); 

    client.end(); 
    } 
}; 

ので、ページ内の「URL()」コマンドは存在しません。 teページでURLを定義し、代わりに "navigate()"を使用する必要があります。

関連する問題