0

I'm currently a little stuck with behat + responsive features that appear / disappear at given break-points on the screen.

The first thing would be to create tags to filter features for devices. Like @iphone or @mobile and so on.

This gets really messy if you are testing on multiple devices with multiple-screen-sizes / orientations. We then would end up with: @iphone5c_hor @iphone5c_vert @iphone5s_hor @iphone5s_vert @samsung..._vert

My second attempt was to tag features with a min-width tag e.g. min-width:700 and to use the feature-context and the webdriver to determine if the current browser I'm on supports the feature I'm trying to execute. This works up until this point:

/**
 * @BeforeFeature
 *
 * @param \Behat\Behat\Hook\Scope\BeforeFeatureScope|BeforeScenarioScope $scope
 */
public function prepareForTheScenario(BeforeScenarioScope $scope)
{
 if (!$this->checkWindowWidth($scope)) {
 // TODO: skip scenario here
 }
}

Has anybody had any experience with these kind of dynamic tests, am I going down a completely wrong way, and If not how can I make that work?

gries
  • 1,135
  • 6
  • 29

2 Answers2

1

I solved it myself by creating a Behat-Extension that supports my needs. (https://github.com/2bepublished/BehatResponsiveFeaturesExtension)

gries
  • 1,135
  • 6
  • 29
0

I had similar issues and had to set browser window size to get rid of my problem. I wonder if this helps you (check it please).

What I did was:

Just set the window size to something bigger so that the menu doesn't get squahed down when testing. You can change the screen size from 1024X768 to something else as you wish.

#symfony/src/Site/CommonBundle/Features/Context/FeatureContext.php

/**
 * @BeforeStep
 */
public function beforeStep()
{
    $this->getSession()->resizeWindow(1024, 768, 'current');
}
Community
  • 1
  • 1
BentCoder
  • 12,257
  • 22
  • 93
  • 165
  • Hi, sorry this is not an option for me as we have atleast 20 different versions of the interface based on the ui and the goal is to test them - so we can be sure that the interface works on the devices. – gries Mar 11 '15 at 10:31
  • I case you need this featue have a look at this extension: https://github.com/2bepublished/BehatResponsiveFeaturesExtension – gries Mar 11 '15 at 14:08