bitovi / syn

Standalone Synthetic Event Library
https://www.npmjs.com/package/syn
MIT License
444 stars 258 forks source link

Syn::focus() dispatch some unwanted events, it closes popup #197

Closed mvorisek closed 1 year ago

mvorisek commented 1 year ago

How to reproduce:

  1. open https://dev.atk4.org/demos/collection/tablefilter.php
  2. click "1st filter arrow" in the table before "Name" column
  3. call Syn::focus - preferably with some JS timeout as navigation to the developer console might have side effects
  4. observe the filter popup div closes, this is not what happens in the reality

here is CI repro: https://github.com/atk4/ui/commit/7598ab592bd8f09c4c78517e811e67ce7d4da9d6

 Feature: Table Filter

  Scenario:                                                                          # tests-behat/filter.feature:3
    Given I am on "collection/tablefilter.php"                                       # Behat\MinkExtension\Context\MinkContext::visit()
    Then I should see "Clear Filters"                                                # Behat\MinkExtension\Context\MinkContext::assertPageContainsText()
    Then I click filter column name "atk_fp_country__name"                           # Atk4\Ui\Behat\Context::iClickFilterColumnName()
    When I fill in "value" with "united kingdom"                                     # Behat\MinkExtension\Context\MinkContext::fillField()
    Then I press button "Set"                                                        # Atk4\Ui\Behat\Context::iPressButton()
      WebDriver\Exception\ElementNotInteractable: element not interactable: [object HTMLDivElement] has no size and location
        (Session info: headless chrome=112.0.5615.165)
      Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
      System info: host: '9dc8ba6dc245', ip: '172.18.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1036-azure', java.version: '11.0.19'
      Driver info: driver.version: unknown in vendor/instaclick/php-webdriver/lib/WebDriver/Exception.php:198
      Stack trace:
      #0 vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php(166): WebDriver\Exception::factory()
      #1 vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php(231): WebDriver\AbstractWebDriver->curl()
      #2 vendor/instaclick/php-webdriver/lib/WebDriver/Container.php(241): WebDriver\AbstractWebDriver->__call()
      #3 src/Behat/MinkSeleniumDriver.php(41): WebDriver\Container->__call()
      #4 vendor/atk4/behat-mink-selenium2-driver/src/Selenium2Driver.php(916): Atk4\Ui\Behat\MinkSeleniumDriver->mouseOverElement()
      #5 vendor/atk4/behat-mink-selenium2-driver/src/Selenium2Driver.php(911): Behat\Mink\Driver\Selenium2Driver->clickOnElement()
      #6 vendor/behat/mink/src/Element/NodeElement.php(153): Behat\Mink\Driver\Selenium2Driver->click()
      #7 src/Behat/Context.php(299): Behat\Mink\Element\NodeElement->click()

with Syn::focus removed the CI passes: https://github.com/atk4/ui/commit/bece190b67ad48b4736134f47b8571fd8df11a52

The same happens in Firefox with slighly different Selenium exception message:

 Feature: Table Filter

  Scenario:                                                                          # tests-behat/filter.feature:3
    Given I am on "collection/tablefilter.php"                                       # Behat\MinkExtension\Context\MinkContext::visit()
    Then I should see "Clear Filters"                                                # Behat\MinkExtension\Context\MinkContext::assertPageContainsText()
    Then I click filter column name "atk_fp_country__name"                           # Atk4\Ui\Behat\Context::iClickFilterColumnName()
    When I fill in "value" with "united kingdom"                                     # Behat\MinkExtension\Context\MinkContext::fillField()
    Then I press button "Set"                                                        # Atk4\Ui\Behat\Context::iPressButton()
      WebDriver\Exception\MoveTargetOutOfBounds: Origin element is not displayed
      Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
      System info: host: '248fc0cda487', ip: '172.18.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1036-azure', java.version: '11.0.19'
      Driver info: driver.version: unknown in vendor/instaclick/php-webdriver/lib/WebDriver/Exception.php:198
      Stack trace:
      #0 vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php(167): WebDriver\Exception::factory()
      #1 vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php(234): WebDriver\AbstractWebDriver->curl()
      #2 vendor/instaclick/php-webdriver/lib/WebDriver/Container.php(241): WebDriver\AbstractWebDriver->__call()
      #3 src/Behat/MinkSeleniumDriver.php(41): WebDriver\Container->__call()
      #4 vendor/atk4/behat-mink-selenium2-driver/src/Selenium2Driver.php(916): Atk4\Ui\Behat\MinkSeleniumDriver->mouseOverElement()
      #5 vendor/atk4/behat-mink-selenium2-driver/src/Selenium2Driver.php(911): Behat\Mink\Driver\Selenium2Driver->clickOnElement()
      #6 vendor/behat/mink/src/Element/NodeElement.php(153): Behat\Mink\Driver\Selenium2Driver->click()
      #7 src/Behat/Context.php(299): Behat\Mink\Element\NodeElement->click()
mvorisek commented 1 year ago

This repro is based on $button->focus();, ie. the problem is in Selenium.