Giter Site home page Giter Site logo

minkphpwebdriver's Introduction

MinkPhpWebDriver

Initially it's started as PR to MinkSelenium2Driver

Major updates include:

  • Switch to using facebook/webdriver
  • Update minimum php version to 8.0
  • Tested against the latest Google Chrome and Mozilla Firefox both in GUI and Headless modes

Setup

Install oleg-andreyev/mink-phpwebdriver

composer require oleg-andreyev/mink-phpwebdriver

Behat Extension

https://github.com/oleg-andreyev/MinkPhpWebdriverExtension

Testing

./bin/start_webdriver.sh &
# ./bin/start_driver.sh <browser> <version>
./bin/start_driver.sh chrome latest &
BROWSER_NAME=chrome ./bin/phpunit

This will download the latest driver for specified browser and will execute phpunit

Running GitHub Acton locally

Follow https://github.com/shivammathur/setup-php#local-testing-setup

Copyright

Copyright (c) 2023 Oleg Andreyev [email protected]

minkphpwebdriver's People

Contributors

andrewnicols avatar dependabot[bot] avatar marinaglancy avatar noeldemartin avatar oleg-andreyev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

minkphpwebdriver's Issues

setValue() TAB causes unintended actions

I agree that it's correct to remove the Syn library. I did the same in my attempt to rewrite the Mink Driver, but I don't think that pressing TAB to trigger the change event is correct.

In a form this may cause something else to be focused which has unintended consequences.

In my early testing I've encountered two issues where this just doesn't work.

In our case, before each element, there is a "Help" icon which displays a Bootstrap popover on focus. In some cases this causes other elements in the DOM to be obscured. For example:

mink-setValue-tab

Likewise we have a field type, "Inplace editable", which transforms a string (i.e. section heading) into a Text input field. It saves the content on [RETURN], but a blur or [ESCAPE] cancels it.

mink-setValue-inplace-editable

Personally I think it wrong for the Mink driver to perform any attempt to blur the field, but the decision we have to make is:
a) do we break from the Mink specification and just set the value. Leave it up to the calling code and/or browser to decide when the Blur should trigger; or
b) fire a new CustomEvent('change', ...) on the Element to mimic the documented behaviour for Mink Drivers; or
c) find a way to actually blur the field without changing the focus; or
d) keep it as is.

The rationale you've made for using TAB is that it prevents multiple change events, but I would argue that's really something that the application should be aware of regardless - I seem to recall that there are times where a browser can cause spammy change events (older versions of IE I think).

In many ways option (b) is the least evil as this is the least unnecessary change from the documented behaviour and is easily achieved:

        $script = <<<EOF
{{ELEMENT}}.dispatchEvent(new Event("change", {
    bubbles: true,
    cancelable: false,
}));
EOF;

        $this->executeJsOnXpath($xpath, $script);

In my mind the 'correct' option is (a), but I suspect that this will cause failures all over the place for people. The setValue() function should only set a value. It should not make assumptions about the nature of page, or how interactions with that element are designed.

I'm happy to provide patches for options a or b. I don't really have any other solutions just yet for c.

Make all methods protected instead of private

I think we should make all of the WebDriver methods protected instead of private to allow it to be extended and modified as required.

There are a couple of valid reasons to do this, but amongst them to there is sometimes a need to make changes which will not be accepted by the project.

As it stands the only ways to do this right now is to fork the project, and add it to the repositories list in composer.json, to use Reflection, or to copy large amounts of code. The fact that this project has had to completely rewrite the Selenium2 driver rather than just extend it and fix the relevant parts is a sign of that too.

So IMHO we should really update all methods to be protected instead of private.

Time to release..?

Any chance we can formally release on packagist to make use easier? We're about to go live with the driver with Moodle.

Move project to php-webdriver/MinkPhpWebDriver

When @OndraM moved the php-webdriver from facebook/php-webdriver to php-webdriver/php-webdriver there was some discussion about the naming of the project there in relation to other projects (php-webdriver/php-webdriver#730 (comment)_).

To improve the sustainability of this project I feel that it might be worth moving it to be under the php-webdriver organisation. Ideally we should also update the namespace (sorry @oleg-andreyev).

Another alternative would be to move it under the MinkPHP project (@stof), but I feel that it makes more sense to link the Mink driver to the underlying Webdriver implementation than to the Mink project itself.

Invalid characters include

Error: Artifact path is not valid: /testKeyboardEvents_with_data_set_"alt-keyUp".png. Contains character: """. Invalid characters include: ",:,<,>,|,*,?.

Exception thrown when outputting junit from Behat

This may or may not be an issue with mink-phpwebdriver, but I have to start somewhere.

When running behat tests with --format=junit, if a test fails, I'm getting the following exception:

Default exception handler: Exception - Call to a member function getPageSource() on null Debug: 
Error code: generalexceptionmessage
* line 456 of /vendor/oleg-andreyev/mink-phpwebdriver/src/WebDriver.php: Error thrown
* line 80 of /vendor/behat/mink/src/Exception/ExpectationException.php: call to OAndreyev\Mink\Driver\WebDriver->getContent()
* line 64 of /vendor/behat/mink/src/Exception/ExpectationException.php: call to Behat\Mink\Exception\ExpectationException->getContext()
* line ? of unknownfile: call to Behat\Mink\Exception\ExpectationException->__toString()
* line 102 of /vendor/behat/behat/src/Behat/Testwork/Exception/ExceptionPresenter.php: call to trim()
* line 57 of /vendor/behat/behat/src/Behat/Behat/Output/Node/Printer/JUnit/JUnitStepPrinter.php: call to Behat\Testwork\Exception\ExceptionPresenter->presentException()
* line 185 of /vendor/behat/behat/src/Behat/Behat/Output/Node/EventListener/JUnit/JUnitFeatureElementListener.php: call to Behat\Behat\Output\Node\Printer\JUnit\JUnitStepPrinter->printStep()
* line 105 of /vendor/behat/behat/src/Behat/Behat/Output/Node/EventListener/JUnit/JUnitFeatureElementListener.php: call to Behat\Behat\Output\Node\EventListener\JUnit\JUnitFeatureElementListener->printFeatureOnAfterEvent()
* line 47 of /vendor/behat/behat/src/Behat/Testwork/Output/Node/EventListener/ChainEventListener.php: call to Behat\Behat\Output\Node\EventListener\JUnit\JUnitFeatureElementListener->listenEvent()
* line 47 of /vendor/behat/behat/src/Behat/Testwork/Output/Node/EventListener/ChainEventListener.php: call to Behat\Testwork\Output\Node\EventListener\ChainEventListener->listenEvent()
* line 90 of /vendor/behat/behat/src/Behat/Testwork/Output/NodeEventListeningFormatter.php: call to Behat\Testwork\Output\Node\EventListener\ChainEventListener->listenEvent()
* line 230 of /vendor/symfony/event-dispatcher/EventDispatcher.php: call to Behat\Testwork\Output\NodeEventListeningFormatter->listenEvent()
* line 59 of /vendor/symfony/event-dispatcher/EventDispatcher.php: call to Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
* line 64 of /vendor/behat/behat/src/Behat/Testwork/EventDispatcher/TestworkEventDispatcher.php: call to Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
* line 48 of /vendor/behat/behat/src/Behat/Testwork/EventDispatcher/TestworkEventDispatcher.php: call to Behat\Testwork\EventDispatcher\TestworkEventDispatcher->bcAwareDispatch()
* line 90 of /vendor/behat/behat/src/Behat/Behat/EventDispatcher/Tester/EventDispatchingFeatureTester.php: call to Behat\Testwork\EventDispatcher\TestworkEventDispatcher->dispatch()
* line 64 of /vendor/behat/behat/src/Behat/Testwork/Tester/Runtime/RuntimeSuiteTester.php: call to Behat\Behat\EventDispatcher\Tester\EventDispatchingFeatureTester->tearDown()
* line 73 of /vendor/behat/behat/src/Behat/Testwork/Hook/Tester/HookableSuiteTester.php: call to Behat\Testwork\Tester\Runtime\RuntimeSuiteTester->test()
* line 75 of /vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingSuiteTester.php: call to Behat\Testwork\Hook\Tester\HookableSuiteTester->test()
* line 71 of /vendor/behat/behat/src/Behat/Testwork/Tester/Runtime/RuntimeExercise.php: call to Behat\Testwork\EventDispatcher\Tester\EventDispatchingSuiteTester->test()
* line 73 of /vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingExercise.php: call to Behat\Testwork\Tester\Runtime\RuntimeExercise->test()
* line 80 of /vendor/behat/behat/src/Behat/Testwork/Ordering/OrderedExercise.php: call to Behat\Testwork\EventDispatcher\Tester\EventDispatchingExercise->test()
* line 149 of /vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php: call to Behat\Testwork\Ordering\OrderedExercise->test()
* line 108 of /vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php: call to Behat\Testwork\Tester\Cli\ExerciseController->testSpecifications()
* line 63 of /vendor/behat/behat/src/Behat/Testwork/Cli/Command.php: call to Behat\Testwork\Tester\Cli\ExerciseController->execute()
* line 298 of /vendor/symfony/console/Command/Command.php: call to Behat\Testwork\Cli\Command->execute()
* line 1040 of /vendor/symfony/console/Application.php: call to Symfony\Component\Console\Command\Command->run()
* line 301 of /vendor/symfony/console/Application.php: call to Symfony\Component\Console\Application->doRunCommand()
* line 124 of /vendor/behat/behat/src/Behat/Testwork/Cli/Application.php: call to Symfony\Component\Console\Application->doRun()
* line 171 of /vendor/symfony/console/Application.php: call to Behat\Testwork\Cli\Application->doRun()
* line 34 of /vendor/behat/behat/bin/behat: call to Symfony\Component\Console\Application->run()
* line 119 of /vendor/bin/behat: call to include()

If tests pass, everything runs smoothly. This is in Moodle, which uses v1.2.1

firefox clickOnElement moveToElement breaks if element is outside viewport

The clickOnElement introduced by #6 leads to a Facebook\WebDriver\Exception\MoveTargetOutOfBoundsException exception if the element to be clicked is visible but not in the current viewport.

Furthermore the specification states:

The Element Click command scrolls into view the element if it is not already pointer-interactable, and clicks its in-view center point.

https://w3c.github.io/webdriver/#element-click

I know that there are some conditions where Firefox does not do this properly in some situations, but the explicit call to moveToElement do not solve this and for me breaks things entirely. That's because gthe moveToElement action simply moves the mouse, it does not move the document within the viewport.

Given all methods in the WebDriver are private, I can't even fix this is my local extension of the driver.

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.