dimanche 17 avril 2016

How can I use phantomjs API methods within my Ember CLI acceptance tests?

Ember's Acceptance Test Helpers provide a nice abstraction layer for writing pure acceptance tests based on user actions, but isn't always enough.

In Ruby/Rails testing with Capybara the underlying test driver (selenium-webdriver, phantomjs, etc), can be accessed in a test case by calling page.driver, then its API used directly to do things not provided by the abstract API, like handling cookies and window sizing.

For example:

page.driver.browser.manage.window.resize_to(width, height)
visit '/foo/bar'
page.driver.browser.action.key_down(:alt).send_keys("c").key_up(:alt).perform

Can this be done in an Ember-CLI project, with default everything (qunit, testem)?

The context for this problem is we have a feature that forces the user to scroll to the bottom before clicking OK (like clickwrap license agreements sometimes make you, but it's for something else). An acceptance test for this is working fine in Chrome, but failing in phantomjs, and we think it's probably because of the window or viewport size. http://ift.tt/1VaGI9F

There may be other ways to fix this, but I'm still interested in accessing the test drivers directly as I think it's a useful tool to have.




Aucun commentaire:

Enregistrer un commentaire