Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 301110

JavascriptTests with webDriver

$
0
0

Problem/Motivation

We are using phantomjs for testing our javascript behaviour.
For the communication with phantomjs we are leveraging gastonjs, which is a port of poltergeist, a quite common library in the ruby and java world.

Poltergeist uses direct communication with phantomjs to control the browser.

An alternative approach is to leverage webdriver, a W3C API, which allows you to
control both phantomjs as well as actual browsers like firefox/chrome using selenium.

This would have the following advantages:

  • You can easier see what is happening in a real browser
  • It is more common than gastonJS to use

Proposed resolution

  1. TODO: Open an issue in the testbot issue queue to still use phantomjs, but using the --webdriver command
  2. Use the mink selenium driver, instead of the gastonjs one.
  3. More details below
  4. Profit?

Remaining tasks

User interface changes

API changes

Data model changes

Testing if Drupal can run with webDriver [1] which allowed running tests under real Browsers.[2]

[1] Bahat official webDriver: http://mink.behat.org/en/latest/drivers/selenium2.html
[2] Testing with different browsers: http://www.seleniumhq.org/download/

Pre-setup:
1. Apply patch
2. `composer require behat/mink-selenium2-driver`

Testing (Firefox):
1. You can follow http://mink.behat.org/en/latest/drivers/selenium2.html to start selenium2

2. Make sure you have Firefox installed in system DEFAULT dir

3. Run PHPUnit test ( same as current system )
e.g.

.\vendor\bin\phpunit.bat -c core core\modules\simpletest\tests\src\FunctionalJavascript\BrowserWithJavascriptTest.php

@droplet created a new simple standard test to avoid Drupal issue

.\vendor\bin\phpunit.bat -c core core\modules\simpletest\tests\src\FunctionalJavascript\StandardTest.php

4. It started firefox and running tests without any problems.

Testing (Phantomjs):
1. Start `phantomjs --webdriver=4444`
(If you have selenium2, you can run via selenium2 also)

2. Change `firefox` to `phantomjs` in $this->minkDefaultDriverArgs
(@see my patch's comment)

3. Same as above step 3 ~ 4

@droplet reports:
Chrome & Firefox:
It run with current testbots system smoothly.

Phantomjs:
Current testbot framework:
It can run but crashed

Unknown errors with Session

$this->drupalGet('<front>');

Patched:
@see FunctionalJavascript\StandardTest.php

It worked!!

I don't familiar with Drupal testbots framework. Looking forward to your feedback from who worked for Drupal JavaScript testbots.


Viewing all articles
Browse latest Browse all 301110

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>