rickypc / selenium-page-object-generator

A nimble and flexible Selenium Page Object Model generator to improve agile testing process velocity.
https://chrome.google.com/webstore/detail/epgmnmcjdhapiojbohkkemlfkegmbebb
GNU Affero General Public License v3.0
122 stars 66 forks source link

Check data for key existence before using #11

Open hubertgrzeskowiak opened 8 years ago

hubertgrzeskowiak commented 8 years ago

Before using data.get(foo) we should look up if the key exists in the map and in case it doesn't do nothing in the default setters. I've changed my own Java template to something like this:

/**
* {{#if argument}}{{argument.documentation}}{{else}}{{operation.documentation}}{{/if}}
*
* @return the {{default target.modelName @root.model.name}} class instance.
*/
public {{default target.modelName @root.model.name}} {{operation.name}}() {
{{#if argument}}
{{#unequals type 'radio'}}
    if (data.containsKey("{{argument.key}})")) {
        return {{operation.name}}(data.get("{{argument.key}}"));
    } else {
        return this;
    }
}