GithubHelp home page GithubHelp logo

Comments (3)

sharathkonda avatar sharathkonda commented on June 18, 2024

Thanks Igor,

Was able to sort out the page objects after sending the email by referring,
var pageObject = this.page.pageObjectFile()
Some reason was only able to refer to the elements by pageObject.elements.elementName.selector
but not by @elementName from past two days.


step definition file:


var home = this.page.home();

    this.assert.visible(home.elements.username.selector);

home.login(centreData.CO.username, centreData.CO.password);
this.page.common().waitForLoaderToDisappear();


Page Object:


var page = {

// page elements (allows @elementkey in tests)
elements : {
    username    : { selector: 'input[id=usn]' },
    password    : { selector: 'input[id=pass]' },
    submit      : { selector: 'input[type=submit]' }
},

// functions to be exposes via the page object via this.page.scriptname().functionname()
functions: {

    login: function(username, password){

        var common = this.api.page.common();

        // always return runtime as this allows chaining within the step methods  
        return common.waitForLoaderToDisappear()
                    .setValue(page.elements.username.selector, username)
                    .setValue(page.elements.password.selector, password)
                    .click(page.elements.submit.selector)
                    .waitForElementVisible(common.elements.logout.selector, 5000);
    }
}

};

// export in a format nightwatch understands
module.exports = {

// commands are exposed within step definition mehtod via this.page.home().functionName  
commands: [page.functions],

// elements selectors allow step definition to use @attributeName to action a selector rather
// than hard coding selectors. For example this.setValue('@username','random-user'); 
elements: page.elements

};

from nightwatch-cucumber.

mucsi96 avatar mucsi96 commented on June 18, 2024

So if I am understanding you correctly the following code snippet is not working for you?

this.page.home().assert.visible('@username');

from nightwatch-cucumber.

sharathkonda avatar sharathkonda commented on June 18, 2024

Regarding

this.page.home().assert.visible('@username');

Its working, I was using this.assert.visible...rather than the
page_object.assert, hence the issue.

Cheers

Sharath Konda

On 31 December 2015 at 08:52, Igor Muchychka [email protected]
wrote:

So if I am understanding you correctly the following code snippet is not
working for you?

this.page.home().assert.visible('@username');


Reply to this email directly or view it on GitHub
#18 (comment)
.

from nightwatch-cucumber.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.