Currently, I am following a specific example to define elements within pageObjects using the ID selector...
var Page = require('./page')
var MyPage= Object.create(Page, {
/**
* defining elements
*/
firstName: { get: function () { return browser.element('#firstName-0'); } },
lastName: { get: function () { return browser.element('#lastName-0'); } },
...
I am interested in finding a method to pass an argument that can dynamically define the selector. For instance, instead of '#firstName-0'
, I would like to be able to use '#firstName-' + i
so that I can capture multiple first names.
I have attempted
firstName: { get: function (i) { return browser.element('#firstName-' + i);}}
then within the test..
MyPage.firstName.get(0).setValue('foo');
however, it gives an error stating that get()
is not a function.
Does anyone have any suggestions?