-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shadow dom #101
Comments
I guess that you want it in WebDriver module. You are welcome to implement this feature and raise pull request. |
The underlying library added support: php-webdriver/php-webdriver#1010 It looks like Firefox added ShadowDom support as well, but still lacks support for some locators, see: w3c/webdriver#1610 so adding support within the module might end in requests why things aren't working which is an underlying issue. |
I came up with the following: diff --git a/src/Codeception/Module/WebDriver.php b/src/Codeception/Module/WebDriver.php
index 2c5b578..51492f1 100644
--- a/src/Codeception/Module/WebDriver.php
+++ b/src/Codeception/Module/WebDriver.php
@@ -1176,9 +1176,9 @@ class WebDriver extends CodeceptionModule implements
public function click($link, $context = null): void
{
- $page = $this->webDriver;
+ $page = $this->getBaseElement();
if ($context) {
- $page = $this->matchFirstOrFail($this->webDriver, $context);
+ $page = $this->matchFirstOrFail($page, $context);
}
$el = $this->_findClickable($page, $link);
@@ -3661,6 +3661,32 @@ class WebDriver extends CodeceptionModule implements
$this->setBaseElement();
}
+ public function performOnShadowRoot($element, $actions, int $timeout = 10): void
+ {
+ $this->waitForElement($element, $timeout);
+ $this->setBaseElement($element);
+ $this->debugSection('InnerText', $this->getBaseElement()->getText());
+
+ $this->baseElement = $this->getBaseElement()->getShadowRoot();
+
+ if (is_callable($actions)) {
+ $actions($this);
+ $this->setBaseElement();
+ return;
+ }
+
+ if (is_array($actions)) {
+ $actions = ActionSequence::build()->fromArray($actions);
+ }
+
+ if (!$actions instanceof ActionSequence) {
+ throw new InvalidArgumentException("2nd parameter, actions should be callback, ActionSequence or array");
+ }
+
+ $actions->run($this);
+ $this->setBaseElement();
+ }
+
/**
* @param string|array|WebDriverBy $element
*/ That way it could be used like this: $this->tester->performOnShadowRoot(
'typo3-backend-new-content-element-wizard',
ActionSequence::build()
->click("//span[normalize-space(.)='$tabName']")
->click("//span[normalize-space(.)='$contentElementLabel']")
); Following the existing I had to fix the Due to all those issues I didn't open a PR. I don't have the feeling general shadow dom support is there yet … But feel free to use the patch and provide a PR or patch your own code. |
What are you trying to achieve?
Get the Shadow Dom
What do you get instead?
Not able to get the result from Shadow root
# paste output here
// paste test
Details
composer show
)# paste suite config here
The text was updated successfully, but these errors were encountered: