module-webdriver
module-webdriver copied to clipboard
`click()` doesn't find `<summary>`, `<label>`, or elements inside `<a>`
The HTML5 element <summary> is missing from the list of clickable elements at WebDriver::_findClickable()
I tried to add it there just like the others: ".//summary[normalize-space(.)=$locator]", - but this doesn't really fix it, since there are many elements allowed inside <summary>: https://html.spec.whatwg.org/#the-summary-element
I think this needs to be refactored, since (from looking at the code) elements inside <a> are also not matched, e.g. <a href="..."><div>...</div></a> - which is valid HTML 5: https://html.spec.whatwg.org/#the-a-element
So I guess the arguments that are thrown into Locator::combine() need to be replaced by functions to allow more complex matching logic.
Workaround: You need to identify the element by some attribute (not by its text content), e.g.:
$I->click(['css' => 'details[id="foo"] summary']);
Clicking on a <label> by its text isn't working too (see https://github.com/Codeception/module-webdriver/issues/21 for the reason I tried it).
I tried to fix it by adding this to WebDriver::_findClickable():
".//label[normalize-space(.)=$locator]"
...but I'm getting this error in the console:
[Facebook\WebDriver\Exception\ElementNotInteractableException] element not interactable (Session info: chrome=85.0.4183.83)
Also, it looks like elements inside <details> are always treated as they can be seen (i.e. dontSeeElement() fails), no matter if the <details> is open or not. But I haven't investigated this further.
Workaround for seeElement() and dontSeeElement() with <details>:
$open = $I->grabAttributeFrom(['css' => 'details.foo'], 'open');
// Assert that <details> is closed:
$I->assertNull($open);
// Assert that <details> is open:
$I->assertSame('true', $open);