Skip to content

Commit

Permalink
Fix a MissingMethodException when Browser.withFrame(Navigator, Class<…
Browse files Browse the repository at this point in the history
…P>, Closure<T>) is called.

Fixes geb/issues#591
  • Loading branch information
erdi committed Oct 18, 2019
1 parent 0795008 commit 8877c7e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/manual/src/docs/asciidoc/140-project.adoc
Expand Up @@ -91,6 +91,7 @@ This page lists the high level changes between versions of Geb.

* Unexpected pages are now only checked after checking that none of the pages passed to `Browser.page()` methods taking a list match. [issue:595[]]
* Fix global atCheckWaiting in combination with to:[...] leading to potentially long delays. [issue:594[]]
* Fix a MissingMethodException when `Browser.withFrame(Navigator, Class<P>, Closure<T>)` is called. [issue:591[]]

=== 3.1

Expand Down
Expand Up @@ -33,15 +33,15 @@ class DefaultFrameSupport implements FrameSupport {
}

public <P extends Page, T> T withFrame(frame, @DelegatesTo.Target Class<P> page, @DelegatesTo(strategy = DELEGATE_FIRST, genericTypeIndex = 0) Closure<T> block) {
executeWithFrame(frame, createPage(page), block)
withFrame(frame, createPage(page), block)
}

public <P extends Page, T> T withFrame(frame, @DelegatesTo.Target P page, @DelegatesTo(strategy = DELEGATE_FIRST) Closure<T> block) {
executeWithFrame(frame, page, block)
}

public <P extends Page, T> T withFrame(Navigator frameNavigator, @DelegatesTo.Target Class<P> page, @DelegatesTo(strategy = DELEGATE_FIRST, genericTypeIndex = 0) Closure<T> block) {
executeWithFrame(frameNavigator, createPage(page), block)
withFrame(frameNavigator, createPage(page), block)
}

public <P extends Page, T> T withFrame(Navigator frameNavigator, @DelegatesTo.Target P page, @DelegatesTo(strategy = DELEGATE_FIRST) Closure<T> block) {
Expand Down Expand Up @@ -78,7 +78,7 @@ class DefaultFrameSupport implements FrameSupport {
}
}

private <T> T executeWithFrame(Navigator frameNavigator, def page, Closure<T> block) {
private <T> T executeWithFrame(Navigator frameNavigator, Page page, Closure<T> block) {
WebElement element = frameNavigator.firstElement()
if (element == null) {
throw new NoSuchFrameException("No elements for given content: ${frameNavigator}")
Expand Down
Expand Up @@ -210,6 +210,14 @@ class FrameSupportSpec extends BaseFrameSupportSpec {
frameFactory << [{ 'header' }, { 0 }, { $('#header-id') }, { page.footer }]
}

def "no method dispatch errors happen when passing page content instance and root Page class to withFrame"() {
when:
withFrame(footer, Page) {}

then:
notThrown(MissingMethodException)
}

private boolean isInFramesContext() {
title == 'frames'
}
Expand Down

0 comments on commit 8877c7e

Please sign in to comment.