Skip to content

Commit

Permalink
add withinFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Aug 6, 2018
1 parent 0533e9b commit 8bfb9f0
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions src/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,23 @@ public function storeConsoleLog($name)
return $this;
}

/**
* Switch to a specified frame in the browser.
*
* @param string $selector
* @return $this
*/
public function withinFrame($selector, Closure $callback)
{
$this->driver->switchTo()->frame($this->resolver->findOrFail($selector));

$callback($this);

$this->driver->switchTo()->defaultContent();

return $this;
}

/**
* Execute a Closure with a scoped browser instance.
*
Expand Down Expand Up @@ -306,6 +323,13 @@ public function with($selector, Closure $callback)
return $this;
}

/**
* Set the current component state.
*
* @param \Laravel\Dusk\Component $component
* @param \Laravel\Dusk\ElementResolver $parentResolver
* @return void
*/
public function onComponent($component, $parentResolver)
{
$this->component = $component;
Expand Down Expand Up @@ -409,23 +433,6 @@ public function stop()
exit();
}

/**
* Switch to a specified frame in the browser.
*
* @param string $selector
* @return $this
*/
public function frame($selector = null)
{
if ($selector) {
$this->driver->switchTo()->frame($this->resolver->findOrFail($selector));
} else {
$this->driver->switchTo()->defaultContent();
}

return $this;
}

/**
* Dynamically call a method on the browser.
*
Expand Down

0 comments on commit 8bfb9f0

Please sign in to comment.