Add session feature + add selenium2 + chrome driver.

pull/2487/head
jmontoyaa 9 years ago
parent 1a24cfd508
commit 97bbcf565b
  1. 8
      .travis.yml
  2. 7
      tests/behat/behat.yml
  3. 77
      tests/behat/features/bootstrap/FeatureContext.php
  4. 2
      tests/behat/features/exercise.feature
  5. 2
      tests/behat/features/link.feature
  6. 8
      tests/behat/features/lp.feature
  7. 41
      tests/behat/features/session.feature
  8. 16
      tests/behat/features/socialGroup.feature
  9. 4
      tests/behat/features/work.feature

@ -51,6 +51,14 @@ before_install:
#- sudo apt-get install -qq php5-cli php5-fpm
before_script:
# setup selenium2 + chrome driver
- wget https://chromedriver.storage.googleapis.com/2.27/chromedriver_linux64.zip && unzip chromedriver_linux64.zip && sudo mv chromedriver /usr/bin
- sh -e /etc/init.d/xvfb start
- export DISPLAY=:99.0
- wget http://selenium-release.storage.googleapis.com/3.1/selenium-server-standalone-3.1.0.jar
- java -jar selenium-server-standalone-3.1.0.jar > /dev/null &
- sleep 5
#- which composer
#- php -d memory_limit=2G /usr/bin/composer update
#- php -d memory_limit=2G /home/travis/.phpenv/shims/composer update

@ -3,7 +3,12 @@ default:
Behat\MinkExtension:
base_url: http://my.chamilo.net
goutte: ~
selenium2: ~
show_cmd: 'open %s'
selenium2:
wd_host: "http://127.0.0.1:4444/wd/hub"
browser: chrome
default_session: selenium2
javascript_session: selenium2
suites:
default:
paths: [ %paths.base%/features ]

@ -294,4 +294,81 @@ class FeatureContext extends MinkContext
"CKEDITOR.instances[\"$fieldId\"].setData(\"$value\");"
);
}
/**
* @Given /^I fill hidden field "([^"]*)" with "([^"]*)"$/
*/
public function iFillHiddenFieldWith($field, $value)
{
$this->getSession()->getPage()->find(
'css',
'input[name="'.$field.'"]'
)->setValue($value);
}
/**
* @When /^(?:|I )fill in select2 input "(?P<field>(?:[^"]|\\")*)" with id "(?P<id>(?:[^"]|\\")*)" and value "(?P<value>(?:[^"]|\\")*)"$/
*/
public function iFillInSelectInputWithAndSelect($field, $id, $value)
{
$page = $this->getSession()->getPage();
$this->getSession()->executeScript("$('$field').select2({data : [{id: $id, text: '$value'}]});");
}
/**
* @When /^(?:|I )confirm the popup$/
*/
public function confirmPopup()
{
// See
// https://gist.github.com/blazarecki/2888851
/** @var \Behat\Mink\Driver\Selenium2Driver $driver Needed because no cross-driver way yet */
//$driver = $this->getSession()->getDriver();
$this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
}
/**
* @When /^(?:|I )fill in select bootstrap input "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)" and select "(?P<entry>(?:[^"]|\\")*)"$/
*/
public function iFillInSelectBootstrapInputWithAndSelect($field, $value, $entry)
{
$page = $this->getSession()->getPage();
$inputField = $page->find('css', $field);
if (!$inputField) {
throw new \Exception('No field found');
}
$choice = $inputField->getParent()->find('css', '.bootstrap-select');
if (!$choice) {
throw new \Exception('No select bootstrap choice found');
}
$choice->press();
$selectInput = $inputField->getParent()->find('css', '.bootstrap-select .form-control');
if (!$selectInput) {
throw new \Exception('No input found');
}
$selectInput->setValue($value);
$this->getSession()->wait(3000);
$chosenResults = $inputField->getParent()->findAll('css', '.dropdown-menu inner li');
foreach ($chosenResults as $result) {
//$option = $result->find('css', '.text');
if ($result->getText() == $entry) {
$result->click();
break;
}
}
}
/**
* @When /^wait for the page to be loaded$/
*/
public function waitForThePageToBeLoaded()
{
//$this->getSession()->wait(10000, "document.readyState === 'complete'");
$this->getSession()->wait(3000);
}
}

@ -6,7 +6,7 @@ Feature: Exercise tool
Given I am a platform administrator
And I am on course "TEMP" homepage
Scenario: Create an exercise
Scenario: Create an exercise
Given I am on "/main/exercise/exercise_admin.php?cidReq=TEMP"
When I fill in the following:
| exercise_title | Exercise 1 |

@ -6,7 +6,7 @@ Feature: Link tool
Given I am a platform administrator
And I am on course "TEMP" homepage
Scenario: Create a link category
Scenario: Create a link category
Given I am on "/main/link/link.php?action=addcategory&cidReq=TEMP"
When I fill in the following:
| category_title | Category 1 |

@ -6,14 +6,14 @@ Feature: LP tool
Given I am a platform administrator
And I am on course "TEMP" homepage
Scenario: Create a LP category
Scenario: Create a LP category
Given I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=add_lp_category"
When I fill in the following:
| name | LP category 1 |
And I press "submit"
Then I should see "Added"
Scenario: Create a LP
Scenario: Create a LP
Given I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=add_lp"
When I fill in the following:
| lp_name | LP 1 |
@ -30,12 +30,12 @@ Feature: LP tool
# And I press "submit_button"
# Then I should see "Document 1"
Scenario: Delete a LP category
Scenario: Delete a LP category
Given I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list"
And I follow "Delete"
Then I should not see "LP category 1"
Scenario: Delete a LP
Scenario: Delete a LP
Given I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list"
And I follow "Delete"
Then I should not see "LP 1"

@ -0,0 +1,41 @@
Feature: Session tool
In order to use the session tool
The admin should be able to create a session
Background:
Given I am a platform administrator
Scenario: Create a session category
Given I am on "/main/session/session_category_add.php"
When I fill in the following:
| name | category_1 |
And I press "Add category"
Then I should see "The category has been added"
@javascript
Scenario: Create a session
Given I am on "/main/session/session_add.php"
When I fill in the following:
| name | Session 1 |
And I fill in select2 input "#coach_username" with id "1" and value "admin"
# And I follow "Advanced settings"
# And I fill in select bootstrap input "#session_category" with "category_1" and select "category_1"
And I press "submit"
Then I should see "Add courses to this session (Session 1)"
Then I select "TEMP (TEMP)" from "NoSessionCoursesList[]"
And I press "add_course"
And I press "next"
Then I should see "Update successful"
Scenario: Delete session
Given I am on "/main/session/session_list.php?keyword=Session+1"
And wait for the page to be loaded
And I follow "Delete"
And I confirm the popup
Then I should see "Deleted"
Scenario: Delete session category
Given I am on "/main/session/session_category_list.php"
And I follow "Delete"
And I confirm the popup
Then I should see "The selected categories have been deleted"

@ -3,14 +3,14 @@ Feature: Social Group
As an administrator
I need to be able to create a social group, invite users and post a message
Scenario: Create a social group
Given I am a platform administrator
And I am on "/main/social/group_add.php"
When I fill in the following:
| name | Behat Test Group |
| description | This is a group created by Behat |
And I press "submit"
Then I should see "Group added"
Scenario: Create a social group
Given I am a platform administrator
And I am on "/main/social/group_add.php"
When I fill in the following:
| name | Behat Test Group |
| description | This is a group created by Behat |
And I press "submit"
Then I should see "Group added"
# Scenario: Invite a friend to group
# Given I am a platform administrator

@ -6,12 +6,10 @@ Feature: Work tool
Given I am a platform administrator
And I am on course "TEMP" homepage
Scenario: Create a work
Scenario: Create a work
Given I am on "/main/work/work.php?action=create_dir&cidReq=TEMP"
When I fill in the following:
| new_dir | Work 1 |
| description | Work description |
And I press "submit"
Then I should see "Directory created"

Loading…
Cancel
Save