Proyectos de Subversion Moodle

Rev

Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
namespace Moodle\BehatExtension\Driver;
18
 
19
use OAndreyev\Mink\Driver\WebDriver as UpstreamDriver;
20
 
21
// phpcs:disable moodle.NamingConventions.ValidFunctionName.LowercaseMethod
22
 
23
/**
24
 * WebDriver Driver to allow extra selenium capabilities required by Moodle.
25
 *
26
 * @package core
27
 * @copyright 2016 onwards Rajesh Taneja
28
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29
 */
30
class WebDriver extends UpstreamDriver {
31
 
32
 
33
    /**
34
     * Dirty attribute to get the browser name; $browserName is private
35
     * @var string
36
     */
37
    protected static $browser;
38
 
39
    /**
40
     * Instantiates the driver.
41
     *
42
     * @param string    $browsername Browser name
43
     * @param array     $desiredcapabilities The desired capabilities
44
     * @param string    $wdhost The WebDriver host
45
     * @param array     $moodleparameters Moodle parameters including our non-behat-friendly selenium capabilities
46
     */
47
    public function __construct(
48
        $browsername = 'chrome',
49
        $desiredcapabilities = null,
50
        $wdhost = 'http://localhost:4444/wd/hub',
51
        $moodleparameters = []
52
    ) {
53
        parent::__construct($browsername, $desiredcapabilities, $wdhost);
54
 
55
        // This class is instantiated by the dependencies injection system so prior to all of beforeSuite subscribers
56
        // which will call getBrowser*().
57
        self::$browser = $browsername;
58
    }
59
 
60
    /**
61
     * Returns the browser being used.
62
     *
63
     * We need to know it:
64
     * - To show info about the run.
65
     * - In case there are differences between browsers in the steps.
66
     *
67
     * @return string
68
     */
69
    public static function getBrowserName() {
70
        return self::$browser;
71
    }
72
 
73
    /**
74
     * Post key on specified xpath.
75
     *
76
     * @param string $key
77
     * @param string $xpath
78
     */
79
    public function post_key($key, $xpath) {
80
        throw new \Exception('No longer used - please use keyDown and keyUp');
81
    }
82
}