Skip to content
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

click() doesn't find <summary>, <label>, or elements inside <a> #18

Open
ThomasLandauer opened this issue Sep 13, 2020 · 4 comments
Open

Comments

@ThomasLandauer
Copy link
Member

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.

@ThomasLandauer
Copy link
Member Author

Workaround: You need to identify the element by some attribute (not by its text content), e.g.:

$I->click(['css' => 'details[id="foo"] summary']);

@ThomasLandauer ThomasLandauer changed the title click() doesn't find <summary> or elements inside <a> click() doesn't find <summary>, <label>, or elements inside <a> Sep 21, 2020
@ThomasLandauer
Copy link
Member Author

Clicking on a <label> by its text isn't working too (see #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)

@ThomasLandauer
Copy link
Member Author

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.

@ThomasLandauer
Copy link
Member Author

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant