Skip to content

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

Description

@ThomasLandauer

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.

Activity

  1. ThomasLandauer commented on Sep 13, 2020

    @ThomasLandauer
    MemberAuthor

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

    $I->click(['css' => 'details[id="foo"] summary']);
  2. changed the title [-]`click()` doesn't find `<summary>` or elements inside `<a>`[/-] [+]`click()` doesn't find `<summary>`, `<label>`, or elements inside `<a>`[/+] on Sep 21, 2020
  3. ThomasLandauer commented on Sep 21, 2020

    @ThomasLandauer
    MemberAuthor

    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)

  4. ThomasLandauer commented on Nov 17, 2020

    @ThomasLandauer
    MemberAuthor

    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.

  5. ThomasLandauer commented on Sep 22, 2021

    @ThomasLandauer
    MemberAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions