Simple behat test failing with @javascrip, passing without

Simple behat test failing with @javascrip, passing without

by Lenka Kolesarova -
Number of replies: 3
Picture of Testers
Hi all,

I tried writing a simple feature expanding on the guest_access.feature from Moodle core, but I cannot get 2 of the 4 scenarios to pass when running in browser with @javascript. When I remove @javascript all the scenarios pass fine.
(my .feature files here attached)

It fails when trying to follow Course 1 from site homepage. The screenshot I get when it fails shows the Course 1 link covered by the header. May this be the problem?

When i tried changing the order in which the courses are created in the background (see attached .feature file), it failed when Teacher 1 tries to follow Course 2 from site homepage in the background part and I get the a similar screenshot.


These are my very first steps with behat and I understand it should be possible to work around this somehow and access the course in a different way, but I am just trying to understand why is this happening?!??

Cheers,
Lenka

I am using local Moodle 3.0+, with behat set up according to this guide https://docs.moodle.org/dev/Acceptance_testing#Installation
Average of ratings: -
In reply to Lenka Kolesarova

Re: Simple behat test failing with @javascrip, passing without

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Try running in Chrome, not FireFox.

Not a great answer, but I have seen that problem, and this is my work-around.

In reply to Lenka Kolesarova

Re: Simple behat test failing with @javascrip, passing without

by Rajesh Taneja -

Hello Lenka,


As OS, browsers and Selenium keeps updating, hence any combination doesn't work and fail randomly.

Please refer https://docs.moodle.org/dev/Acceptance_testing/Browsers#Working_combinations_of_OS.2BBrowser.2Bselenium and try with any combination which has been used by Moodle HQ.

In reply to Rajesh Taneja

Re: Simple behat test failing with @javascrip, passing without

by Lenka Kolesarova -
Picture of Testers
Thanks for quick advice Tim and Rajesh,

I finally have it working in Chrome Version 47.0 with selenium-server-standalone-2.47.1.jar with Chrome driver 2.19 on Ubuntu 15.10

I tried downgrading to Chrome v46.0 that you recommend, but couldn't find a download of this version for Ubuntu. Anyway, it seems to work fine in the 47.0 version too, the tests which were failing for me previously are now passing.

So just to list the steps I did to make it working in Chrome in case there are other people in my situation:

1. download previous version of selenium

I have used selenium-server-standalone-2.47.1.jar downloaded from http://selenium-release.storage.googleapis.com/index.html?path=2.47/

and place in /opt

2. download previous version of chrome driver

I have used version 2.19 http://chromedriver.storage.googleapis.com/index.html?path=2.19/

unzip and place in /opt

3. add this to config.php

$CFG->behat_config = array(
   'default' => array(
       'extensions' => array(
           'Behat\MinkExtension\Extension' => array(
               'selenium2' => array(
                   'browser' => 'chrome',
               )
           )
       )
   ),
   'chrome-linux' => array(
           'extensions' => array(
               'Behat\MinkExtension\Extension' => array(
                   'selenium2' => array(
                       'browser' => 'chrome',
                       'wd_host' => 'http://localhost:8000'
                   )
               )
           )
       )
);


4. then start selenium AND chrome driver

java -jar /opt/selenium-server-standalone-2.47.1.jar -Dwebdriver.chrome.driver=/opt/chromedriver
and then run tests as usual, the same way as in firefox, but the @javascript ones are now running in Chrome and not failing when trying to click on stuff smile

Thanks again and Merry Christmas & Happy New Year! (hopefully I won't do any more behat testing until 2016! tongueout )

Lenka