Skip to content

Question: use of Syn instead of native selenium calls #78

Closed

Description

@robsquires

I'm using this driver to test an large angularJS application. A fair amount of our UI behaviour is delivered using CSS as well as javascript...:hover being an example.

I've been experiencing issues when elements aren't available for clicking because they are not displayed. I presume this is because javascript events are being used (via syn) instead of the native mouse movements available in selenium.

I imagine you've a very good reason for doing this (i've seen https://github.com/Behat/MinkSelenium2Driver/issues/51) relating to compatibility across browsers? Does the selenium server not provide this abstraction very effectively?

Anyhow I've forked and replaced a few commands with native webdriver calls as I don't want our frontend devs to get too wrapped up in the internals of the webdriver api - they're pretty happy with the mink api.

I'll continue to use my fork but I'm wondering if you've plans to adopt more of the native api calls into the mink API?

Activity

  1. aik099 commented on Sep 6, 2013

    @aik099
    Member

    Hi,

    can you be more specific about stuff, that doesn't work for you? If we're looking at situation in general, then it's up to individual driver (e.g. Selenium, Sahi, etc.) to to use one or another approach in implementing specific user interaction with a browser.

    If there is a proof, that Selenium native implementation of some functionality does call all the JS events properly (in all browsers of course), then we surely can skip using Syn there.

    But I recommend to be careful with massive changes. Instead let's just focus on stuff that doesn't work for you and analyze alternative (you have PR ready already?), that would do what you need plus all tests will be still passing.

  2. robsquires commented on Sep 12, 2013

    @robsquires
    Author

    I've created a project to test this specific case: https://github.com/robsquires/Selenium-Tests

    If you run the feature suite you'll see a failing test + the screenshot generated in /screenshot confirms the CSS :hover state is not being triggered.

    I'm using phantomjs in webdriver mode. I've not tested cross browser as I'm not sure what support you are going for - could you confirm?

    The quick + dirty change I mentioned above can be seen here

  3. aik099 commented on Sep 12, 2013

    @aik099
    Member

    I see, current mouseOver implementation does emulate the mouseover event, but doesn't really move mouse anywhere 😄

    What if you, in current mouseOver method implementation, change code to do $this->wdSession->moveTo ...? If that would:

    1. move the mouse to desired element
    2. fire mouseover events along the way
    3. cause :hover css selector to work

    then you can safely send a PR for this case.

  4. robsquires commented on Sep 12, 2013

    @robsquires
    Author

    Yup thanks, that's all cool. The code I posted uses moveTo + I'll happily submit a PR for that change.

    In relation to this question - what was behind the implementation decision to use syn as opposed to the native selenium calls?

  5. aik099 commented on Sep 12, 2013

    @aik099
    Member

    I wasn't there at decision (whatever to use Syn or not) making time, but looking at Selenium server development it looks like, that it had problems with firing native JavaScript events when being used.

    Then things have changed (for Selenium server), but Mink driver wasn't updated to reflect that. The related #51 issue, that you mentioned, proves that. I'll watch closely for Syn to be replaced with native calls for cases, where Syn won't be doing it's job properly in emulating real user action.

  6. robsquires commented on Sep 12, 2013

    @robsquires
    Author

    Ok thanks

  7. aik099 commented on Sep 12, 2013

    @aik099
    Member

    @robsquires , why you closed this task? Shouldn't you be submitting PR instead and associating it with this task?

  8. robsquires commented on Sep 12, 2013

    @robsquires
    Author

    yeah you're right...sorry :)

  9. robsquires commented on Sep 12, 2013

    @robsquires
    Author

    Excuse this slightly nooby question..What's the best way for me to get my proposed changes into the codebase.

    I added a web-fixture for this issue to the Mink package. Now I realise I'm not going to be able to update Mink through composer as the dependancy is ~1.5.0 :(

    It doesn't look like any test cases have been added to Selenium2DriverTest for a while - what's the best approach to get these changes in?

    thanks

  10. aik099 commented on Sep 12, 2013

    @aik099
    Member

    It doesn't look like any test cases have been added to Selenium2DriverTest for a while - what's the best approach to get these changes in?

    This is because all drivers should identically simulate user actions and all tests are placed in following folder: https://github.com/Behat/Mink/tree/develop/tests/Behat/Mink/Driver

    I guess you need to add new test to JavascriptDriverTest.php. This test would cover that :hover effect testing. However you must also test that both Selenium1 and Sahi driver would pass that new test too.

  11. aik099 commented on Sep 12, 2013

    @aik099
    Member

    Here is how I usually do this:

    1. add all needed code to Mink, but don't commit yet
    2. have working repo clone for each of drivers under test (selenium1/2, sahi)
    3. copy updated mink code to vendor folder within drivers replacing 1.5.0 version of Mink, which there already
    4. run tests for each driver
  12. robsquires commented on Sep 13, 2013

    @robsquires
    Author

    thanks. I've taken a similar approach in my working repo. I was worried about travis really. Composer will install mink 1.5.0 during the build so my tests won't be there...any ideas?

    In terms of adding a test to JavascriptDriverTest.php I don't think that's advisable. This issue actually relates to CSS and not javascript - i.e the driver's ability for behaviour implemented in CSS to be accurately tested. If this test was added, the suite would always fail for the zombie driver.

    I can add a specific test case for the issue (378) to the selenium 1 and sahi drivers to ensure they work in the same way.

  13. aik099 commented on Sep 13, 2013

    @aik099
    Member

    So you suggest, that current implementation of mouseOver method in a driver isn't covered by tests right now?

  14. 10 remaining items

  15. robsquires commented on Sep 13, 2013

    @robsquires
    Author

    would you mind just explaining that actually. composer require behat/mink=1.5.*@dev will add "behat/mink": "1.5.*dev" to composer.json...isn't that the correct way to specify the deps, as opposed to using the branch alias?

  16. aik099 commented on Sep 13, 2013

    @aik099
    Member

    Branch alias is there to match branch, that isn't named as version (e.g. develop in this case) to some version, when comparing versions. I guess I just trust you on this one, since I don't have time to double check that over Composer manual.

  17. robsquires commented on Sep 13, 2013

    @robsquires
    Author

    ha - ok, well i'll double double check and do the right thing ;-)

  18. aik099 commented on Dec 2, 2013

    @aik099
    Member

    @robsquires , I've solved problem, where tests added to Mink weren't immediately available on it's driver's PR's when doing tests by replacing ~1.5 to ~1.5@dev in composer.json of each driver.

  19. andrewnicols commented on Feb 21, 2014

    @andrewnicols

    For the record, I've just raised these bugs with the Syn library, and have found fixes. We too were finding issues with our tests randomly failing on pages where scrollbars were removed and the Syn library caused the page to jump thus moving the elements which should be visible, out of the window.

    I've raised a couple of issues relating to this:
    bitovi/syn#29 - firefox bug with the href JS detection
    bitovi/syn#30 - firefox bug whereby including the library causes the browser focus to jump

    Applying these fixes gets us back to a passing state on all of our failing tests.

    It looks like the Syn library is being actively maintained once more and the maintainers are working to improve code quality (bitovi/syn#32).

  20. aik099 commented on Feb 21, 2014

    @aik099
    Member

    Yes, they even start to number versions from zero back again.

  21. J7mbo commented on Apr 9, 2014

    @J7mbo

    A fair amount of our UI behaviour is delivered using CSS as well as javascript...:hover being an example.

    Does this still exist? Can we trigger :hover with mouseOver() yet?

  22. aik099 commented on Apr 9, 2014

    @aik099
    Member

    @J7mbo have you tried it and it doesn't work for you?

  23. J7mbo commented on Apr 9, 2014

    @J7mbo

    @aik099 Yes, but I wanted to confirm that I'm not doing something stupid before asking for help :-)

  24. aik099 commented on Apr 9, 2014

    @aik099
    Member

    I see, that you've created #125 about that topic. Just referencing it here so both issues are linked properly.

    This Syn() issue has been around for while, but without a solid research we can't really change anything.

    So we have code of 2 types:

    1. pure Syn() call to emulate JS event
    2. native WebDriver call to do something

    On some browser/platform/window manager combinations some of JS events, that occur during native WebDriver call doesn't occur at all. Here Syn() comes to play and emulates them.

    Problem is that on some other browser/platform/window manager combinations these native events occur and Syn is triggering a duplicate JS event causing bad things to happen.

    Ideally at the end we need to have a table if "browser x platform x window_manager x event" where we can see what's been natively triggered by Selenium WebDriver.

  25. aik099 commented on Apr 9, 2014

    @aik099
    Member

    @ALL, the SauceLabs (https://saucelabs.com/platforms) or BrowserStack (http://www.browserstack.com/list-of-browsers-and-platforms?product=live) are free for OpenSource so we write some tests to verify what JS events are fired by native Selenium calls (VS ones that should be fired) then we can adjust current Syn() calls to make more sense.

  26. aik099 commented on Apr 9, 2014

    @aik099
    Member

    Maybe we need to create a separate repo, that will:

    1. use mink & mink selenium2 driver
    2. connect to saucelabs
    3. will only run tests to verify what JS events are fired by Selenium VS ones that are fired when action is done by user
  27. aik099 commented on Apr 14, 2014

    @aik099
    Member

    I'll close this task since functionality is already merged in the #126. Feel free to reopen if needed.

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