TIMBERings
TIMBERings

Reputation: 768

Watir PageObject Indexed_Property not using string substitution

In a couple places, I'm creating an indexed_property, but when I call it, the index is always 1.

example screenshot

indexed_property(:team, [
  [:span, :team, {css: 'article#AssignTeams-Teams table tr:nth-child(%s) td:nth-child(1) span'}]
])

Implemented:

assign_teams_page.team[5].team_element

When I put a break point on it and make the call, the element's selector is:

article#AssignTeams-Teams table tr:nth-child(1) td:nth-child(1) span

it should be tr:nth-child(5) instead of tr:nth-child(1). Why am I seeing this, how do I fix it?

Upvotes: 0

Views: 160

Answers (1)

Alexis Andersen
Alexis Andersen

Reputation: 805

There's a current bug in page-object 1.0.2 that causes indexed properties to retain the definition of the first time you call them. So if you called:

assign_teams_page.team[1].team_element
assign_teams_page.team[5].team_element

It would be using the index 1 every time. There is a fix in place but not released yet. You can fix the issue by downgrading to page-object 1.0.0 or upgrading to 1.0.3 when it comes out.

Upvotes: 2

Related Questions