When running behat tests with Selenium2 driver an error is shown:
Request header is not supported by Behat\Mink\Driver\Selenium2Driver
Selenium driver gives similar error.
This comes from those lines in DrupalContext.php:
$ua = drupal_generate_test_ua('simpletest65');
$session->setRequestHeader('User-Agent', $ua);
Is this header really needed? If yes, it seems that may be the behat_drupal module should send this header using some hook so heeader is set but no Selenium error is thrown. Currently any Selenium driver can't be used for behat testing with behat_testing module.
Comments
Comment #1
Pete B commentedHi tunic,
We use this to hook into simpletests method of changing the database (http://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/_drup...)
Without this, I can't see a way of switching the database at an early enough stage. Not many hooks are fired before this stage.
You're right though, it's unfortunate that this loses us Selenium support. If you have any suggestions we would be very grateful!
Thanks,
Pete
Comment #2
tunicYes, unfortunately there's no hook before _drupal_bootstrap_database call (it's logical because hooks are cached in database, it'd be a nonsense to scan all files in every page request looking for an early hook). I can't see any simple way to change database preffix without that header.
There's a issue in Selenium about setting headers: http://code.google.com/p/selenium/issues/detail?id=2047
In that issue they recommend to use a proxy, BrowserMob, to inject additional headers.
If Behat Testing sets this header only when databse is cloned Selenium drivers could be used when tests are run directly on real database. This is a possible scenario in stage/dev/testing environments.
If I investigate more on BrowserMob proxy I'll post my thoughts here and we can discuss if it's a good solution for this issue when database is cloned and Selenium driver is needed.
Comment #3
Pete B commentedGood stuff tunic, I would love to hear how you get on.
Comment #4
johnennew commentedThe header is not set on the live profile so if you have a separate site instance just for testing you can use the live profile on that. Don't run this on a version of the site you don't want the tests to mess with the content on though!
drush --profile=live