Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the driver #1

Merged
merged 47 commits into from
Dec 9, 2023
Merged

Implement the driver #1

merged 47 commits into from
Dec 9, 2023

Conversation

uuf6429
Copy link
Member

@uuf6429 uuf6429 commented Jun 10, 2023

Remaining Tasks

@codecov
Copy link

codecov bot commented Jun 10, 2023

Welcome to Codecov 🎉

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered ☂️

phpunit.xml.dist Outdated Show resolved Hide resolved
.gitattributes Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
src/WebdriverClassicDriver.php Outdated Show resolved Hide resolved
src/WebdriverClassicDriver.php Outdated Show resolved Hide resolved
src/WebdriverClassicDriver.php Outdated Show resolved Hide resolved
src/WebdriverClassicDriver.php Outdated Show resolved Hide resolved
src/WebdriverClassicDriver.php Outdated Show resolved Hide resolved
@stof stof changed the title First commit Implement the driver Jun 12, 2023
stof
stof previously requested changes Jun 12, 2023
src/WebdriverClassicDriver.php Outdated Show resolved Hide resolved
tests/Custom/TimeoutTest.php Outdated Show resolved Hide resolved
src/WebdriverClassicDriver.php Outdated Show resolved Hide resolved
@uuf6429

This comment was marked as resolved.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
phpunit.xml.dist Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
stof

This comment was marked as resolved.

@stof

This comment was marked as resolved.

@uuf6429 uuf6429 marked this pull request as ready for review June 18, 2023 17:49
@uuf6429 uuf6429 requested review from aik099, oleg-andreyev and stof June 18, 2023 17:50
@uuf6429 uuf6429 assigned uuf6429 and unassigned uuf6429 Jun 18, 2023
@uuf6429

This comment was marked as outdated.

Comment on lines 21 to +33
<var name="driver_config_factory" value="Mink\WebdriverClassDriver\Tests\WebdriverClassicConfig::getInstance"/>
<!--server name="WEB_FIXTURES_HOST" value="http://test.mink.dev" /-->

<server name="WEB_FIXTURES_HOST" value="http://host.docker.internal:8002"/>
<!-- MacOS -->
<!--<server name="WEB_FIXTURES_HOST" value="http://docker.for.mac.localhost:8002"/>-->
<!--<server name="WEB_FIXTURES_BROWSER" value="firefox"/>-->

<!-- where driver will connect to -->
<server name="DRIVER_URL" value="http://localhost:4444/wd/hub"/>

<!-- where DocumentRoot of 'Test Machine' is mounted to on 'Driver Machine' (only if these are 2 different machines) -->
<!--server name="DRIVER_MACHINE_BASE_PATH" value="" /-->
<!--server name="TEST_MACHINE_BASE_PATH" value="" /-->
<server name="DRIVER_MACHINE_BASE_PATH" value="/fixtures/"/>

<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the defaults of this section would result in the developer's inability to run the test suite with a locally started Selenium server.

Copy link
Member Author

@uuf6429 uuf6429 Jul 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replied to this point already, but I guess it got somehow lost: #1 (comment)

That still stands, the recommended test setup is with docker, therefore the defaults are tailored for docker. In case developers want to customize this, they can easily create their own phpunit.xml (that won't be committed with the project).

@aik099

This comment was marked as outdated.

@uuf6429

This comment was marked as outdated.

@uuf6429 uuf6429 dismissed stof’s stale review July 9, 2023 20:35

I'd like a rereview

protected function supportsCss(): bool
{
return true;
}

private function isXvfb(): bool

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misleading method name. why you need it?

Copy link
Member Author

@uuf6429 uuf6429 Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misleading method name

It's not exactly misleading - it's what we are actually intending there by checking the github action env var.

That check was originally implemented in MinkSelenium2Driver:
https://github.com/minkphp/MinkSelenium2Driver/blob/master/tests/Selenium2Config.php#L38

After trial and error, I found what it was trying to do, hence the name I gave it. Maybe we can find a better name though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/WebdriverClassicConfig.php Show resolved Hide resolved
'chrome' => [
'goog:chromeOptions' => [
// disable "Chrome is being controlled.." notification bar
'excludeSwitches' => ['enable-automation'],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it affect something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean...the comment describes exactly what it does...removing the notification bar means there's more rendering space and less unexpected UI potentially interfering with tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The situation for Edge is similar, except that for some weird reason, it refuses to even start when with any settings (but that seems to be something else).

src/WebdriverClassicDriver.php Outdated Show resolved Hide resolved
$name
): ?string {
$escapedName = $this->jsonEncode($name, 'get attribute', 'attribute name');
$script = "return arguments[0].getAttribute($escapedName)";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @param string $browserName One of 'edge', 'firefox', 'chrome' or any one of {@see WebDriverBrowserType} constants.
*/
public function __construct(
string $browserName = self::DEFAULT_BROWSER,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stof recently I found that the proper browser name for MSEdge is "MicrosoftEdge".
For some reason, "edge" used to work before, but not anymore.
At the moment, we use the browser name from the docker image suffix, which eventually triggered the problem I just mentioned.

However, this got me thinking, at the moment there aren't any restrictions or suggestions for the browser name from the mink side, which is far from ideal especially since we have extra (default) initialization logic based on the browser name.

On the other hand, I'm not sure it's a good idea to tell the dev to use constants from a 3rd party library (what I sort of the in the phpdoc). I took the liberty to say exactly which browsers are definitely supported in the PHPDoc, which is effectively the keys from BROWSER_NAME_ALIAS_MAP. Another approach could be to define our own constants, or provide them in a new class that extends WebDriverBrowserType.

What do you think?


case WebDriverBrowserType::MICROSOFT_EDGE:
return DesiredCapabilities::microsoftEdge()
->setCapability(WebDriverCapabilityType::PLATFORM, WebDriverPlatform::ANY);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@stof stof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the usage of syn.js, I'd rather keep the initial implementation free of it, marking methods as unsupported and skipping tests if needed.

syn.js is quite a bad fit as it does not actually simulate the actual browser events. See minkphp/driver-testsuite#36 (comment)

Note that we might have to deprecate the existing keypress, keyup and keydown methods as they don't reflect reality: an actual browser has no way to interact in a way that triggers only one of those events.

use Facebook\WebDriver\WebDriverDimension;
use JetBrains\PhpStorm\Language;
use JsonException;
use Throwable;

This comment was marked as resolved.

src/WebdriverClassicDriver.php Outdated Show resolved Hide resolved
src/WebdriverClassicDriver.php Show resolved Hide resolved
src/WebdriverClassicDriver.php Outdated Show resolved Hide resolved
src/WebdriverClassicDriver.php Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
@stof

This comment was marked as resolved.

@uuf6429

This comment was marked as resolved.

@uuf6429 uuf6429 requested a review from stof October 22, 2023 13:02
Copy link
Member

@stof stof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's finally merge this and keep follow-up works in other PRs

@stof stof merged commit 3a116f9 into minkphp:main Dec 9, 2023
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants