-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
we still need custom driver class as the fork is tested with old FIrefox
- Loading branch information
Showing
3 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Atk4\Ui\Behat; | ||
|
||
use Atk4\Core\WarnDynamicPropertyTrait; | ||
use WebDriver\Element as WebDriverElement; | ||
|
||
class MinkSeleniumDriver extends \Behat\Mink\Driver\Selenium2Driver | ||
{ | ||
use WarnDynamicPropertyTrait; | ||
|
||
public function __construct(\Behat\Mink\Driver\Selenium2Driver $driver) // @phpstan-ignore-line | ||
{ | ||
$class = self::class; | ||
while (($class = get_parent_class($class)) !== false) { | ||
\Closure::bind(function () use ($driver) { | ||
foreach (get_object_vars($driver) as $k => $v) { | ||
$this->{$k} = $v; | ||
} | ||
}, $this, $class)(); | ||
} | ||
} | ||
|
||
public function getText($xpath): string | ||
{ | ||
// HTMLElement::innerText returns rendered text as when copied to the clipboard | ||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | ||
// https://github.com/minkphp/MinkSelenium2Driver/pull/327 | ||
// https://github.com/minkphp/MinkSelenium2Driver/pull/328 | ||
return $this->executeJsOnXpath($xpath, 'return {{ELEMENT}}.innerText;'); | ||
} | ||
|
||
protected function mouseOverElement(WebDriverElement $element): void | ||
{ | ||
// move the element into the viewport | ||
// needed at least for Firefox as Selenium moveto does move the mouse cursor only | ||
$this->executeScript('arguments[0].scrollIntoView({ behaviour: \'instant\', block: \'center\', inline: \'center\' })', [$element]); | ||
|
||
$this->getWebDriverSession()->moveto(['element' => $element->getID()]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters