Behat @javascript scenarios can’t be logged as admin


#1

Hi there,

I lately got my hands on Behat and of course took Sylius as my playground !

As I was trying to understand how to work with mink and selenium, I encounter an UnxpectedPageException while running @javascript scenarios which needed admin authentication (eg. in ui_managing_countries suite), Selenium is running correctly except that the request is always redirected to the admin login page which throws the exception. I’m always trying to sort things on my own but this time I really can’t figure out why the AdminSecurityContext is not doing his job here !

I must have done something wrong while setting up my local environnement for tests. Here are the main steps I follow:

  • Install latest Selenium & chromedriver
  • Clone the Sylius repo & run composer install, sylius:install, gulp & sylius:assets:install for test environnement
  • Setting up the database for test environnement
  • Running php server on port 8080 & running selenium
  • Then running behat

Does anyone already saw this or could help me with it ? Let me know if you need more informations to help me get through this.

Thanks a lot, it’s really great to have a nice forum for the Sylius community !


#2

Could you post the commands that you use to run PHP server and Selenium? Have you changed the Behat or security configuration?


#3

Thanks for your answer @pamil. I didn’t change anything in the security or behat config. I follow the steps of the testing-behat-with-js travis script & ran the following commands to run Chromedriver, Selenium & PHP server (I made sure to create the $SYLIUS_CACHE_DIR, export the variable, download & move both selenium & chromedriver into it) :

  • $SYLIUS_CACHE_DIR/chromedriver
  • java -Dwebdriver.chrome.driver=$SYLIUS_CACHE_DIR/chromedriver -jar $SYLIUS_CACHE_DIR/selenium.jar
  • bin/console server:run 127.0.0.1:8080 -d public --env=test --no-debug
  • and then ran behat with: vendor/bin/behat --strict --no-interaction --tags="@javascript && ~@todo && ~@cli"

I really don’t know where it could come from, I’m running it on OSX, so I thought it could be my machine setup, but I also created a docker environnement (I can create a repo with it if you want) and found the same issue with the browser redirected to the login page when it needs to access some secure area.

Do you have any clue ? I’m a bit desperate here !