GithubHelp home page GithubHelp logo

webdriver-classic-driver's Introduction

Mink WebDriver Classic Driver

Latest Stable Version Latest Unstable Version Total Downloads CI License codecov

Usage Example

<?php

use Behat\Mink\Mink,
    Behat\Mink\Session,
    Mink\WebdriverClassicDriver\WebdriverClassicDriver;

require_once __DIR__ . '/vendor/autoload.php';

$browserName = 'firefox';
$url = 'http://example.com';

$mink = new Mink(array(
    'webdriver-classic' => new Session(new WebdriverClassicDriver($browserName)),
));

$session = $mink->getSession('webdriver-classic');
$session->visit($url);

$session->getPage()->findLink('Chat')->click();

Please refer to MinkExtension-example for an executable example.

Installation

composer require behat/mink mink/webdriver-classic-driver

Testing

  1. Start WebDriver
    1. If you have Docker installed, run
    docker run -p 4444:4444 selenium/standalone-firefox:4.18.1
    1. If you do not have Docker, but you have Java
    curl -L https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.18.0/selenium-server-4.18.1.jar > selenium-server-4.18.1.jar
    java -jar selenium-server-4.18.1.jar standalone
  2. Start WebServer by running
    ./vendor/bin/mink-test-server
  3. Start PhpUnit
    ./vendor/bin/phpunit -v --coverage-clover=coverage.clover

webdriver-classic-driver's People

Contributors

uuf6429 avatar stof avatar aik099 avatar

Stargazers

Oleg Andreyev avatar Alex Skrypnyk avatar Thanh Trần avatar

Watchers

Konstantin Kudryashov avatar  avatar  avatar Oleg Andreyev avatar  avatar  avatar

Forkers

uuf6429 stof aik099

webdriver-classic-driver's Issues

Move test web server startup/shutdown to the GitHub Actions workflow

Currently, the https://github.com/minkphp/webdriver-classic-driver/blob/main/tests/bootstrap.php file automatically starts/stops the web server with test fixtures used during testing. This is an innovative approach compared to how other drivers would do this.

If we go away from the current approach (start web server inside a test suite), then all that stuff needs to be moved into the GitHub Actions workflow (as in other drivers).

Possible downsides to the current approach (I'm not saying it's a wrong approach in general):

  • Project contributors might already have a Web Server running locally and this project cloned in its DocumentRoot. In that scenario, they don't need another Web Server to be started and only need to map paths in the phpunit.xml.
  • The 8002 port might be already occupied on the contributor's machine, which would result in the inability to run tests.
  • The Symfony's Process component is being used, but it's not explicitly listed as a dev dependency in the composer and that means, that it's not guaranteed to be present as a dependency.

Why the clearing approach of "setValue" method was changed compared to the Selenium2 driver?

The Selenium2 driver was typing Backspace (for Windows) + Delete (for Mac) keys to the input/textarea in the amount needed to erase the current value. That allowed any JavaScript code of that page, that monitored input/textarea value change (e.g., to prevent certain keys from being typed) to behave as if a real human was doing this.

This driver uses the clear method of the WebDriver to clear the input/textarea value.

Does it fire necessary JS keyboard events in the process as well in every Selenium+Browser combination being tested?

P.S.

  • We're likely not having tests to verify that behavior.
  • The clear WebDriver method might be changing element focus, which might fire a duplicate focus/blur event when using clear+sendKeys together.

Rename driver/test namespaces in the PHP files

The namespaces of the PHP classes (both src and tests folders) need to be standardized to match other Mink drivers:

  • namespace for the src folder: Behat\Mink\Driver;
  • namespace for the tests folder: Behat\Mink\Tests\Driver.

Replace usage of "arguments[0]" with "{{ELEMENT}}"

The https://github.com/minkphp/MinkSelenium2Driver/blob/master/src/Selenium2Driver.php uses {{ELEMENT}} to mask the internal element representation of an element in the driver (my understanding). Later it replaces it with arguments[0] when preparing JS code for a WebDriver.

This driver, however, exposes arguments[0] instead.

I think, that this also is a BC break, because developers now can't switch to this driver without replacing {{ELEMENT}} across their test suite first.

Please use the {{ELEMENT}} as in the current Mink's Selenium2 driver (or at least in the public API of the driver).

The `Session::reset` throws an exception when main window has name

When the main window has a name and a couple of other windows are open, then the Session::reset call throws a NoSuchWindow exception, because it tries to determine the main window handle by its name after a popup window was just deleted while Selenium is in context of that deleted window (Web View).

Maybe for the internal window manipulations, the driver should use only window handles.

Related issue: #25

P.S.
I stumbled upon this error after fixing the #25 problem locally.

The `Session::reset` closes main window, when window was renamed

How to reproduce:

  1. start a session either by calling the Session::visit
    • an empty window is opened with an empty window.name (because no URL is opened yet)
    • initial window handle becomes w3cwh:{selenium_window_handle_here}
    • the page URL is visited
    • the page sets it's window.name to the desired value
  2. open some other popups from that page
  3. call the Session::reset:
    • the Session::swithToWindow() works correctly, because it uses selenium-handle-based window identifier
    • code, that cycles through the opened windows isn't identifying an initial window (because it has a different name) and such and is closing it

For now the only option, that might work is to consider 1st opened window as initial (the 1st window handle returned) and never close it.

Related issue: #26

Fix driver namespace

I just realised that the namespace might be wrong, we have Mink\WebdriverClassDriver - shouldn't it be Mink\WebdriverClassicDriver?

@stof

Replace syn.js

If possible, use selenium action api for all cases.

If not, consider using a syn alternative (or if to complex, depend on syn) for old selenium.

Update readme

  • Mention supported/tested selenium/browser and any version-specific problems
  • Installation (standard composer stuff)
  • Usage
    • in behat
    • in mink
    • individually
  • How to run tests
    • individually
      • with docker
      • with native selenium (+mention custom phpunit config)
    • in bulk with act
  • Tests to ensure readme examples are not broken

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.