Skip to content

Commit

Permalink
Add internal wait when finding by text
Browse files Browse the repository at this point in the history
fixes #229
  • Loading branch information
samccone committed Sep 24, 2014
1 parent 3f5ba5b commit 92ed30b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/widgets/Widget.coffee
Expand Up @@ -182,14 +182,19 @@ $ = Driver.promise
@root + (if selector then " #{selector}" else '')

_findByText: (opts) ->
@find().then (el) ->
el.findElement(
# WebDriver lets you go out of the child scope
# if you pass an absolute xpath selector
# this is a bug in WebDriver and is terrible
# by passing a `.` this is no longer an issue.
Driver.By.xpath('.//*[normalize-space(text())=normalize-space("' + opts.text + '")]')
)
# WebDriver lets you go out of the child scope
# if you pass an absolute xpath selector
# this is a bug in WebDriver and is terrible
# by passing a `.` this is no longer an issue.
_selector = Driver.By.xpath('.//*[normalize-space(text())=normalize-space("' + opts.text + '")]')

@find().then (el) =>
@driver.wait(
_.bind(el.findElement, el, _selector),
global.timeout,
"Unable to find node containing text #{opts.text}"
).then =>
el.findElement(_selector)

_ensureElement: (selector) ->
@driver.wait(
Expand Down

0 comments on commit 92ed30b

Please sign in to comment.