Issue #3421202 by alexpott, longwave, andypost, justafish: Enable W3C-compliant webdriver testing
parent
24b7c3ffa3
commit
9eb4cb9d5b
|
@ -1,4 +1,4 @@
|
|||
# cspell:ignore drupaltestbot drupaltestbotpw
|
||||
# cspell:ignore drupaltestbot drupaltestbotpw Dwebdriver logfile XVFB
|
||||
|
||||
stages:
|
||||
- 🗜️ Test
|
||||
|
@ -14,7 +14,7 @@ variables:
|
|||
POSTGRES_DB: drupaltestbot
|
||||
POSTGRES_USER: drupaltestbot
|
||||
POSTGRES_PASSWORD: drupaltestbotpw
|
||||
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--disable-dev-shm-usage","--disable-gpu","--headless"]}}, "http://localhost:9515"]'
|
||||
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome", "goog:chromeOptions":{"w3c": true, "args":["--no-sandbox","--ignore-certificate-errors", "--allow-insecure-localhost", "--headless", "--dns-prefetch-disable"]}}, "http://selenium:4444"]'
|
||||
|
||||
'🩹 Test-only changes':
|
||||
stage: 🗜️ Test
|
||||
|
@ -29,14 +29,14 @@ variables:
|
|||
services:
|
||||
- name: $_CONFIG_DOCKERHUB_ROOT/$_TARGET_DB:production
|
||||
alias: database
|
||||
- name: $_CONFIG_DOCKERHUB_ROOT/chromedriver:production
|
||||
alias: chrome
|
||||
entrypoint:
|
||||
- chromedriver
|
||||
- "--no-sandbox"
|
||||
- "--log-path=/tmp/chromedriver.log"
|
||||
- "--verbose"
|
||||
- "--whitelisted-ips="
|
||||
- name: selenium/standalone-chrome:latest
|
||||
alias: selenium
|
||||
variables:
|
||||
JAVA_OPTS: "-Dwebdriver.chrome.logfile=/builds/chromedriver.log"
|
||||
SE_NODE_OVERRIDE_MAX_SESSIONS: "true"
|
||||
SE_NODE_MAX_SESSIONS: "5"
|
||||
SE_START_XVFB: "false"
|
||||
SE_START_VNC: "false"
|
||||
before_script:
|
||||
- |
|
||||
[[ $_TARGET_DB == sqlite* ]] && export SIMPLETEST_DB=sqlite://localhost/$CI_PROJECT_DIR/sites/default/files/db.sqlite?module=sqlite
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# cspell:ignore cobertura drupaltestbot drupaltestbotpw
|
||||
# cspell:ignore cobertura drupaltestbot drupaltestbotpw Dwebdriver logfile XVFB
|
||||
|
||||
stages:
|
||||
- 🗜️ Test
|
||||
|
@ -67,7 +67,8 @@ variables:
|
|||
POSTGRES_DB: drupaltestbot
|
||||
POSTGRES_USER: drupaltestbot
|
||||
POSTGRES_PASSWORD: drupaltestbotpw
|
||||
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--disable-dev-shm-usage","--disable-gpu","--headless","--dns-prefetch-disable"]}}, "http://localhost:9515"]'
|
||||
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome", "goog:chromeOptions":{"w3c": true, "args":["--no-sandbox","--ignore-certificate-errors", "--allow-insecure-localhost", "--headless", "--dns-prefetch-disable"]}}, "http://selenium:4444"]'
|
||||
MINK_DRIVER_ARGS_WEBDRIVER_CHROMEDRIVER_NON_W3C: '["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--disable-dev-shm-usage","--disable-gpu","--headless","--dns-prefetch-disable"]}}, "http://localhost:9515"]'
|
||||
CI_PARALLEL_NODE_INDEX: $CI_NODE_INDEX
|
||||
CI_PARALLEL_NODE_TOTAL: $CI_NODE_TOTAL
|
||||
|
||||
|
@ -85,6 +86,16 @@ variables:
|
|||
- "--whitelisted-ips="
|
||||
- "--allowed-origins=*"
|
||||
|
||||
.with-selenium-chrome: &with-selenium-chrome
|
||||
name: selenium/standalone-chrome:latest
|
||||
alias: selenium
|
||||
variables:
|
||||
JAVA_OPTS: "-Dwebdriver.chrome.logfile=/builds/chromedriver.log"
|
||||
SE_NODE_OVERRIDE_MAX_SESSIONS: "true"
|
||||
SE_NODE_MAX_SESSIONS: "5"
|
||||
SE_START_XVFB: "false"
|
||||
SE_START_VNC: "false"
|
||||
|
||||
.run-tests: &run-tests
|
||||
script:
|
||||
# Need to pass this along directly.
|
||||
|
@ -125,14 +136,34 @@ variables:
|
|||
|
||||
'🖱️️️ PHPUnit Functional Javascript':
|
||||
<<: [ *with-composer, *run-tests, *default-job-settings ]
|
||||
parallel: 2
|
||||
parallel: 4
|
||||
variables:
|
||||
TESTSUITE: PHPUnit-FunctionalJavascript
|
||||
CONCURRENCY: 15
|
||||
KUBERNETES_CPU_REQUEST: "24"
|
||||
services:
|
||||
- <<: *with-database
|
||||
- <<: *with-selenium-chrome
|
||||
after_script:
|
||||
- echo $MINK_DRIVER_ARGS_WEBDRIVER
|
||||
- sed -i "s#$CI_PROJECT_DIR/##" ./sites/default/files/simpletest/phpunit-*.xml || true
|
||||
- cp /builds/chromedriver.log ./
|
||||
|
||||
'🖱️️️ PHPUnit Functional Javascript (non W3C legacy)':
|
||||
<<: [ *with-composer, *default-job-settings ]
|
||||
parallel: 1
|
||||
variables:
|
||||
TESTSUITE: PHPUnit-FunctionalJavascript
|
||||
CONCURRENCY: 15
|
||||
KUBERNETES_CPU_REQUEST: "24"
|
||||
MINK_DRIVER_ARGS_WEBDRIVER: $MINK_DRIVER_ARGS_WEBDRIVER_CHROMEDRIVER_NON_W3C
|
||||
services:
|
||||
- <<: *with-database
|
||||
- <<: *with-chrome
|
||||
script:
|
||||
# Run a small subset of tests to prove non W3C testing still works.
|
||||
- sudo MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data php ./core/scripts/run-tests.sh --color --keep-results --types "$TESTSUITE" --concurrency "$CONCURRENCY" --repeat "1" --sqlite "./sites/default/files/tests.sqlite" --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --verbose --non-html javascript
|
||||
|
||||
after_script:
|
||||
- sed -i "s#$CI_PROJECT_DIR/##" ./sites/default/files/simpletest/phpunit-*.xml || true
|
||||
- cp /builds/chromedriver.log ./
|
||||
|
@ -208,7 +239,7 @@ variables:
|
|||
KUBERNETES_CPU_REQUEST: "24"
|
||||
services:
|
||||
- <<: *with-database
|
||||
- <<: *with-chrome
|
||||
- <<: *with-selenium-chrome
|
||||
script:
|
||||
- export DRUPAL_TEST_DB_URL=$SIMPLETEST_DB
|
||||
- cp ./core/.env.example ./core/.env
|
||||
|
@ -218,9 +249,10 @@ variables:
|
|||
- echo "DRUPAL_TEST_BASE_URL='http://localhost/subdirectory'" >> ./core/.env
|
||||
- echo "DRUPAL_TEST_CHROMEDRIVER_AUTOSTART=false" >> ./core/.env
|
||||
- echo "DRUPAL_TEST_DB_URL='${DRUPAL_TEST_DB_URL}'" >> ./core/.env
|
||||
- echo "DRUPAL_TEST_WEBDRIVER_HOSTNAME='localhost'" >> ./core/.env
|
||||
- echo "DRUPAL_TEST_WEBDRIVER_HOSTNAME='selenium'" >> ./core/.env
|
||||
- echo "DRUPAL_TEST_WEBDRIVER_CHROME_ARGS='--disable-dev-shm-usage --disable-gpu --headless --dns-prefetch-disable'" >> ./core/.env
|
||||
- echo "DRUPAL_TEST_WEBDRIVER_PORT='9515'" >> ./core/.env
|
||||
- echo "DRUPAL_TEST_WEBDRIVER_W3C=true" >> ./core/.env
|
||||
- echo "DRUPAL_TEST_WEBDRIVER_PORT='4444'" >> ./core/.env
|
||||
- echo "DRUPAL_NIGHTWATCH_OUTPUT='"../nightwatch_output"'" >> ./core/.env
|
||||
- echo "COLUMNS=1000" >> ./core/.env
|
||||
- chown -R www-data:www-data ./sites /var/www
|
||||
|
@ -253,12 +285,12 @@ variables:
|
|||
- if: $PERFORMANCE_TEST == "1"
|
||||
variables:
|
||||
KUBERNETES_CPU_REQUEST: "24"
|
||||
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--disable-dev-shm-usage","--disable-gpu","--headless","--no-sandbox"]}}, "http://chrome:9515"]'
|
||||
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome", "goog:chromeOptions":{"w3c": true, "args":["--no-sandbox","--ignore-certificate-errors", "--allow-insecure-localhost", "--headless", "--dns-prefetch-disable", "--no-sandbox"]}}, "http://selenium:4444"]'
|
||||
tags:
|
||||
- performance-test-runner
|
||||
services:
|
||||
- <<: *with-database
|
||||
- <<: *with-chrome
|
||||
- <<: *with-selenium-chrome
|
||||
script:
|
||||
# Determine DB driver.
|
||||
- |
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
"composer/composer": "^2.7.7",
|
||||
"drupal/coder": "^8.3.10",
|
||||
"justinrainbow/json-schema": "^5.2",
|
||||
"lullabot/mink-selenium2-driver": "^1.7",
|
||||
"lullabot/php-webdriver": "^2.0.4",
|
||||
"lullabot/mink-selenium2-driver": "^1.7.3",
|
||||
"lullabot/php-webdriver": "^2.0.5",
|
||||
"mglaman/phpstan-drupal": "^1.2.10",
|
||||
"micheh/phpcs-gitlab": "^1.1",
|
||||
"mikey179/vfsstream": "^1.6.11",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "63f0b59ba81213ad8f8e124c60a8bb82",
|
||||
"content-hash": "a7381d9c8398db71aa38d0efa7daa309",
|
||||
"packages": [
|
||||
{
|
||||
"name": "asm89/stack-cors",
|
||||
|
@ -5417,22 +5417,22 @@
|
|||
},
|
||||
{
|
||||
"name": "lullabot/mink-selenium2-driver",
|
||||
"version": "v1.7.2",
|
||||
"version": "v1.7.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Lullabot/MinkSelenium2Driver.git",
|
||||
"reference": "5f9ecc2dc329d87442843f6143a4307a62fc5f8c"
|
||||
"reference": "91445897dda062790a741003c9c85d9bb2f902cf"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Lullabot/MinkSelenium2Driver/zipball/5f9ecc2dc329d87442843f6143a4307a62fc5f8c",
|
||||
"reference": "5f9ecc2dc329d87442843f6143a4307a62fc5f8c",
|
||||
"url": "https://api.github.com/repos/Lullabot/MinkSelenium2Driver/zipball/91445897dda062790a741003c9c85d9bb2f902cf",
|
||||
"reference": "91445897dda062790a741003c9c85d9bb2f902cf",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"behat/mink": "^1.11@dev",
|
||||
"ext-json": "*",
|
||||
"lullabot/php-webdriver": "^2.0",
|
||||
"lullabot/php-webdriver": "^2.0.5",
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"replace": {
|
||||
|
@ -5483,22 +5483,22 @@
|
|||
"webdriver"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/Lullabot/MinkSelenium2Driver/tree/v1.7.2"
|
||||
"source": "https://github.com/Lullabot/MinkSelenium2Driver/tree/v1.7.3"
|
||||
},
|
||||
"time": "2024-02-12T10:40:39+00:00"
|
||||
"time": "2024-07-17T16:07:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "lullabot/php-webdriver",
|
||||
"version": "v2.0.4",
|
||||
"version": "v2.0.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Lullabot/php-webdriver.git",
|
||||
"reference": "55fb15bd92663c3f90f42b2c79ca3ee11f2d7925"
|
||||
"reference": "b686c5fe74ae4f3d5f7ff6e45234d99562de9ff4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Lullabot/php-webdriver/zipball/55fb15bd92663c3f90f42b2c79ca3ee11f2d7925",
|
||||
"reference": "55fb15bd92663c3f90f42b2c79ca3ee11f2d7925",
|
||||
"url": "https://api.github.com/repos/Lullabot/php-webdriver/zipball/b686c5fe74ae4f3d5f7ff6e45234d99562de9ff4",
|
||||
"reference": "b686c5fe74ae4f3d5f7ff6e45234d99562de9ff4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -5530,9 +5530,10 @@
|
|||
"webtest"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/Lullabot/php-webdriver/tree/v2.0.4"
|
||||
"issues": "https://github.com/Lullabot/php-webdriver/issues",
|
||||
"source": "https://github.com/Lullabot/php-webdriver/tree/v2.0.5"
|
||||
},
|
||||
"time": "2024-07-04T09:19:59+00:00"
|
||||
"time": "2024-07-17T15:21:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "mglaman/phpstan-drupal",
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
"composer/composer": "^2.7.7",
|
||||
"drupal/coder": "^8.3.10",
|
||||
"justinrainbow/json-schema": "^5.2",
|
||||
"lullabot/mink-selenium2-driver": "^1.7",
|
||||
"lullabot/php-webdriver": "^2.0.4",
|
||||
"lullabot/mink-selenium2-driver": "^1.7.3",
|
||||
"lullabot/php-webdriver": "^2.0.5",
|
||||
"mglaman/phpstan-drupal": "^1.2.10",
|
||||
"micheh/phpcs-gitlab": "^1.1",
|
||||
"mikey179/vfsstream": "^1.6.11",
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
"drupal/coder": "8.3.24",
|
||||
"google/protobuf": "v3.25.3",
|
||||
"justinrainbow/json-schema": "5.3.0",
|
||||
"lullabot/mink-selenium2-driver": "v1.7.2",
|
||||
"lullabot/php-webdriver": "v2.0.4",
|
||||
"lullabot/mink-selenium2-driver": "v1.7.3",
|
||||
"lullabot/php-webdriver": "v2.0.5",
|
||||
"mglaman/phpstan-drupal": "1.2.11",
|
||||
"micheh/phpcs-gitlab": "1.1.0",
|
||||
"mikey179/vfsstream": "v1.6.11",
|
||||
|
|
|
@ -46,6 +46,9 @@ DRUPAL_TEST_CHROMEDRIVER_AUTOSTART=true
|
|||
# e.g. `--disable-gpu --headless --no-sandbox`.
|
||||
#DRUPAL_TEST_WEBDRIVER_CHROME_ARGS=
|
||||
|
||||
# Use W3C webdriver commands.
|
||||
#DRUPAL_TEST_WEBDRIVER_W3C=true
|
||||
|
||||
# A list of arguments to pass to Webdriver, separated by spaces
|
||||
# e.g. `--allowed-ips --disable-dev-shm-usage`.
|
||||
#DRUPAL_TEST_WEBDRIVER_CLI_ARGS=
|
||||
|
|
|
@ -10,7 +10,7 @@ class BigPipeRegressionTestController implements TrustedCallbackInterface {
|
|||
|
||||
const MARKER_2678662 = '<script>var hitsTheFloor = "</body>";</script>';
|
||||
|
||||
const PLACEHOLDER_COUNT = 3000;
|
||||
const PLACEHOLDER_COUNT = 2000;
|
||||
|
||||
/**
|
||||
* @see \Drupal\Tests\big_pipe\FunctionalJavascript\BigPipeRegressionTest::testMultipleBodies_2678662()
|
||||
|
|
|
@ -90,9 +90,7 @@ class ContextualLinksTest extends WebDriverTestBase {
|
|||
// as it would with a real user interaction. Otherwise clickContextualLink()
|
||||
// does not open the dialog in a manner that is opener-aware, and it isn't
|
||||
// possible to reliably test focus management.
|
||||
$driver_session = $this->getSession()->getDriver()->getWebDriverSession();
|
||||
$element = $driver_session->element('css selector', '#block-branding');
|
||||
$driver_session->moveto(['element' => $element->getID()]);
|
||||
$this->getSession()->getDriver()->mouseOver('.//*[@id="block-branding"]');
|
||||
$this->clickContextualLink('#block-branding', 'Test Link with Ajax', FALSE);
|
||||
$this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', '#drupal-modal'));
|
||||
$this->assertSession()->elementContains('css', '#drupal-modal', 'Everything is contextual!');
|
||||
|
|
|
@ -284,7 +284,7 @@ class LayoutBuilderDisableInteractionsTest extends WebDriverTestBase {
|
|||
// After the contextual link opens the dialog, move the mouse pointer
|
||||
// elsewhere on the page. If mouse up were not working correctly this would
|
||||
// actually drag the body field too.
|
||||
$this->movePointerTo('#iframe-that-should-be-disabled');
|
||||
$this->getSession()->getDriver()->mouseOver('.//*[@id="iframe-that-should-be-disabled"]');
|
||||
|
||||
$new_body_block_bottom_position = $this->getElementVerticalPosition($body_field_selector, 'bottom');
|
||||
$iframe_top_position = $this->getElementVerticalPosition('#iframe-that-should-be-disabled', 'top');
|
||||
|
@ -324,8 +324,14 @@ class LayoutBuilderDisableInteractionsTest extends WebDriverTestBase {
|
|||
*
|
||||
* @param string $selector
|
||||
* CSS selector.
|
||||
*
|
||||
* @deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Use
|
||||
* $this->getSession()->getDriver()->mouseOver() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3460567
|
||||
*/
|
||||
protected function movePointerTo($selector) {
|
||||
@trigger_error(__METHOD__ . '() is deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Use $this->getSession()->getDriver()->mouseOver() instead. See https://www.drupal.org/node/3460567', E_USER_DEPRECATED);
|
||||
$driver_session = $this->getSession()->getDriver()->getWebDriverSession();
|
||||
$element = $driver_session->element('css selector', $selector);
|
||||
$driver_session->moveto(['element' => $element->getID()]);
|
||||
|
|
|
@ -12,9 +12,8 @@ class TestController {
|
|||
var timesRun = 0;
|
||||
var interval = setInterval(function() {
|
||||
timesRun += 1;
|
||||
// Clear the interval after 1.1 seconds as this is longer than the time
|
||||
// WebDriverCurlService would retry for if retries are enabled but shorter
|
||||
// than the 10 seconds JSWebAssert::waitForElementVisible() waits for.
|
||||
// Clear the interval after 1.1 seconds as this is shorter than the 10 seconds
|
||||
// JSWebAssert::waitForElementVisible() waits for.
|
||||
if (timesRun === 1100) {
|
||||
clearInterval(interval);
|
||||
}
|
||||
|
|
|
@ -45,88 +45,97 @@ module.exports = {
|
|||
browser.drupalUninstall();
|
||||
},
|
||||
'Drupal.Toolbar.models': (browser) => {
|
||||
browser.execute(
|
||||
function () {
|
||||
const toReturn = {};
|
||||
const { models } = Drupal.toolbar;
|
||||
toReturn.hasMenuModel = models.hasOwnProperty('menuModel');
|
||||
toReturn.menuModelType = typeof models.menuModel === 'object';
|
||||
toReturn.hasToolbarModel = models.hasOwnProperty('toolbarModel');
|
||||
toReturn.toolbarModelType = typeof models.toolbarModel === 'object';
|
||||
toReturn.toolbarModelActiveTab =
|
||||
models.toolbarModel.get('activeTab').id ===
|
||||
'toolbar-item-administration';
|
||||
toReturn.toolbarModelActiveTray =
|
||||
models.toolbarModel.get('activeTray').id ===
|
||||
'toolbar-item-administration-tray';
|
||||
toReturn.toolbarModelIsOriented =
|
||||
models.toolbarModel.get('isOriented') === true;
|
||||
toReturn.toolbarModelIsFixed =
|
||||
models.toolbarModel.get('isFixed') === true;
|
||||
toReturn.toolbarModelAreSubtreesLoaded =
|
||||
models.toolbarModel.get('areSubtreesLoaded') === false;
|
||||
toReturn.toolbarModelIsViewportOverflowConstrained =
|
||||
models.toolbarModel.get('isViewportOverflowConstrained') === false;
|
||||
toReturn.toolbarModelOrientation =
|
||||
models.toolbarModel.get('orientation') === 'horizontal';
|
||||
toReturn.toolbarModelLocked =
|
||||
models.toolbarModel.get('locked') === null;
|
||||
toReturn.toolbarModelIsTrayToggleVisible =
|
||||
models.toolbarModel.get('isTrayToggleVisible') === true;
|
||||
toReturn.toolbarModelHeight = models.toolbarModel.get('height') === 79;
|
||||
toReturn.toolbarModelOffsetsBottom =
|
||||
models.toolbarModel.get('offsets').bottom === 0;
|
||||
toReturn.toolbarModelOffsetsLeft =
|
||||
models.toolbarModel.get('offsets').left === 0;
|
||||
toReturn.toolbarModelOffsetsRight =
|
||||
models.toolbarModel.get('offsets').right === 0;
|
||||
toReturn.toolbarModelOffsetsTop =
|
||||
models.toolbarModel.get('offsets').top === 80;
|
||||
toReturn.toolbarModelSubtrees =
|
||||
models.menuModel.get('subtrees') === null;
|
||||
return toReturn;
|
||||
},
|
||||
[],
|
||||
(result) => {
|
||||
const expectedTrue = {
|
||||
hasMenuModel: 'has menu model',
|
||||
menuModelType: 'menu model is an object',
|
||||
hasToolbarModel: 'has toolbar model',
|
||||
toolbarModelType: 'toolbar model is an object',
|
||||
toolbarModelActiveTab: 'get("activeTab") has expected result',
|
||||
toolbarModelActiveTray: 'get("activeTray") has expected result',
|
||||
toolbarModelIsOriented: 'get("isOriented") has expected result',
|
||||
toolbarModelIsFixed: 'get("isFixed") has expected result',
|
||||
toolbarModelAreSubtreesLoaded:
|
||||
'get("areSubtreesLoaded") has expected result',
|
||||
toolbarModelIsViewportOverflowConstrained:
|
||||
'get("isViewportOverflowConstrained") has expected result',
|
||||
toolbarModelOrientation: 'get("orientation") has expected result',
|
||||
toolbarModelLocked: 'get("locked") has expected result',
|
||||
toolbarModelIsTrayToggleVisible:
|
||||
'get("isTrayToggleVisible") has expected result',
|
||||
toolbarModelHeight: 'get("height") has expected result',
|
||||
toolbarModelOffsetsBottom:
|
||||
'get("offsets") bottom has expected result',
|
||||
toolbarModelOffsetsLeft: 'get("offsets") left has expected result',
|
||||
toolbarModelOffsetsRight: 'get("offsets") right has expected result',
|
||||
toolbarModelOffsetsTop: 'get("offsets") top has expected result',
|
||||
toolbarModelSubtrees: 'get("subtrees") has expected result',
|
||||
};
|
||||
browser.assert.deepEqual(
|
||||
Object.keys(expectedTrue).sort(),
|
||||
Object.keys(result.value).sort(),
|
||||
'Keys to check match',
|
||||
);
|
||||
Object.keys(expectedTrue).forEach((property) => {
|
||||
browser.assert.equal(
|
||||
result.value[property],
|
||||
true,
|
||||
expectedTrue[property],
|
||||
browser
|
||||
.waitForElementPresent(
|
||||
'#toolbar-item-administration-tray',
|
||||
50000,
|
||||
1000,
|
||||
false,
|
||||
)
|
||||
.execute(
|
||||
function () {
|
||||
const toReturn = {};
|
||||
const { models } = Drupal.toolbar;
|
||||
toReturn.hasMenuModel = models.hasOwnProperty('menuModel');
|
||||
toReturn.menuModelType = typeof models.menuModel === 'object';
|
||||
toReturn.hasToolbarModel = models.hasOwnProperty('toolbarModel');
|
||||
toReturn.toolbarModelType = typeof models.toolbarModel === 'object';
|
||||
toReturn.toolbarModelActiveTab =
|
||||
models.toolbarModel.get('activeTab').id ===
|
||||
'toolbar-item-administration';
|
||||
toReturn.toolbarModelActiveTray =
|
||||
models.toolbarModel.get('activeTray').id ===
|
||||
'toolbar-item-administration-tray';
|
||||
toReturn.toolbarModelIsOriented =
|
||||
models.toolbarModel.get('isOriented') === true;
|
||||
toReturn.toolbarModelIsFixed =
|
||||
models.toolbarModel.get('isFixed') === true;
|
||||
toReturn.toolbarModelAreSubtreesLoaded =
|
||||
models.toolbarModel.get('areSubtreesLoaded') === false;
|
||||
toReturn.toolbarModelIsViewportOverflowConstrained =
|
||||
models.toolbarModel.get('isViewportOverflowConstrained') === false;
|
||||
toReturn.toolbarModelOrientation =
|
||||
models.toolbarModel.get('orientation') === 'horizontal';
|
||||
toReturn.toolbarModelLocked =
|
||||
models.toolbarModel.get('locked') === null;
|
||||
toReturn.toolbarModelIsTrayToggleVisible =
|
||||
models.toolbarModel.get('isTrayToggleVisible') === true;
|
||||
toReturn.toolbarModelHeight =
|
||||
models.toolbarModel.get('height') === 79;
|
||||
toReturn.toolbarModelOffsetsBottom =
|
||||
models.toolbarModel.get('offsets').bottom === 0;
|
||||
toReturn.toolbarModelOffsetsLeft =
|
||||
models.toolbarModel.get('offsets').left === 0;
|
||||
toReturn.toolbarModelOffsetsRight =
|
||||
models.toolbarModel.get('offsets').right === 0;
|
||||
toReturn.toolbarModelOffsetsTop =
|
||||
models.toolbarModel.get('offsets').top === 80;
|
||||
toReturn.toolbarModelSubtrees =
|
||||
models.menuModel.get('subtrees') === null;
|
||||
return toReturn;
|
||||
},
|
||||
[],
|
||||
(result) => {
|
||||
const expectedTrue = {
|
||||
hasMenuModel: 'has menu model',
|
||||
menuModelType: 'menu model is an object',
|
||||
hasToolbarModel: 'has toolbar model',
|
||||
toolbarModelType: 'toolbar model is an object',
|
||||
toolbarModelActiveTab: 'get("activeTab") has expected result',
|
||||
toolbarModelActiveTray: 'get("activeTray") has expected result',
|
||||
toolbarModelIsOriented: 'get("isOriented") has expected result',
|
||||
toolbarModelIsFixed: 'get("isFixed") has expected result',
|
||||
toolbarModelAreSubtreesLoaded:
|
||||
'get("areSubtreesLoaded") has expected result',
|
||||
toolbarModelIsViewportOverflowConstrained:
|
||||
'get("isViewportOverflowConstrained") has expected result',
|
||||
toolbarModelOrientation: 'get("orientation") has expected result',
|
||||
toolbarModelLocked: 'get("locked") has expected result',
|
||||
toolbarModelIsTrayToggleVisible:
|
||||
'get("isTrayToggleVisible") has expected result',
|
||||
toolbarModelHeight: 'get("height") has expected result',
|
||||
toolbarModelOffsetsBottom:
|
||||
'get("offsets") bottom has expected result',
|
||||
toolbarModelOffsetsLeft: 'get("offsets") left has expected result',
|
||||
toolbarModelOffsetsRight:
|
||||
'get("offsets") right has expected result',
|
||||
toolbarModelOffsetsTop: 'get("offsets") top has expected result',
|
||||
toolbarModelSubtrees: 'get("subtrees") has expected result',
|
||||
};
|
||||
browser.assert.deepEqual(
|
||||
Object.keys(expectedTrue).sort(),
|
||||
Object.keys(result.value).sort(),
|
||||
'Keys to check match',
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
Object.keys(expectedTrue).forEach((property) => {
|
||||
browser.assert.equal(
|
||||
result.value[property],
|
||||
true,
|
||||
expectedTrue[property],
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
'Change tab': (browser) => {
|
||||
browser.execute(
|
||||
|
|
|
@ -50,16 +50,16 @@ class CommandsTest extends WebDriverTestBase {
|
|||
// Wait for the alert to appear.
|
||||
$page->waitFor(10, function () use ($session) {
|
||||
try {
|
||||
$session->getDriver()->getWebDriverSession()->getAlert_text();
|
||||
$session->getDriver()->getWebDriverSession()->alert()->getText();
|
||||
return TRUE;
|
||||
}
|
||||
catch (\Exception) {
|
||||
return FALSE;
|
||||
}
|
||||
});
|
||||
$alert_text = $this->getSession()->getDriver()->getWebDriverSession()->getAlert_text();
|
||||
$alert_text = $this->getSession()->getDriver()->getWebDriverSession()->alert()->getText();
|
||||
$this->assertEquals('Alert', $alert_text);
|
||||
$this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
|
||||
$this->getSession()->getDriver()->getWebDriverSession()->alert()->accept();
|
||||
|
||||
$this->drupalGet($form_path);
|
||||
$page->pressButton("AJAX 'Announce': Click to announce");
|
||||
|
|
|
@ -141,8 +141,8 @@ JS;
|
|||
$session->visit($url);
|
||||
|
||||
// There are 2 alerts to accept before we can get the content of the page.
|
||||
$session->getDriver()->getWebdriverSession()->accept_alert();
|
||||
$session->getDriver()->getWebdriverSession()->accept_alert();
|
||||
$session->getDriver()->getWebdriverSession()->alert()->accept();
|
||||
$session->getDriver()->getWebdriverSession()->alert()->accept();
|
||||
|
||||
$out = $session->getPage()->getContent();
|
||||
|
||||
|
|
|
@ -9,44 +9,12 @@ use Behat\Mink\Exception\DriverException;
|
|||
use WebDriver\Element;
|
||||
use WebDriver\Exception;
|
||||
use WebDriver\Exception\UnknownError;
|
||||
use WebDriver\ServiceFactory;
|
||||
|
||||
/**
|
||||
* Provides a driver for Selenium testing.
|
||||
*/
|
||||
class DrupalSelenium2Driver extends Selenium2Driver {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($browserName = 'firefox', $desiredCapabilities = NULL, $wdHost = 'http://localhost:4444/wd/hub') {
|
||||
parent::__construct($browserName, $desiredCapabilities, $wdHost);
|
||||
ServiceFactory::getInstance()->setServiceClass('service.curl', WebDriverCurlService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setCookie($name, $value = NULL) {
|
||||
if ($value === NULL) {
|
||||
$this->getWebDriverSession()->deleteCookie($name);
|
||||
return;
|
||||
}
|
||||
|
||||
$cookieArray = [
|
||||
'name' => $name,
|
||||
'value' => urlencode($value),
|
||||
'secure' => FALSE,
|
||||
// Unlike \Behat\Mink\Driver\Selenium2Driver::setCookie we set a domain
|
||||
// and an expire date, as otherwise cookies leak from one test site into
|
||||
// another.
|
||||
'domain' => parse_url($this->getWebDriverSession()->url(), PHP_URL_HOST),
|
||||
'expires' => time() + 80000,
|
||||
];
|
||||
|
||||
$this->getWebDriverSession()->setCookie($cookieArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads a file to the Selenium instance and returns the remote path.
|
||||
*
|
||||
|
|
|
@ -50,7 +50,6 @@ class DrupalSelenium2DriverTest extends WebDriverTestBase {
|
|||
public function testGetRemoteFilePath(): void {
|
||||
$web_driver = $this->getSession()->getDriver();
|
||||
$this->assertInstanceOf(Selenium2Driver::class, $web_driver);
|
||||
$this->assertFalse($web_driver->isW3C(), 'Driver is not operating in W3C mode');
|
||||
|
||||
$file_system = \Drupal::service('file_system');
|
||||
$entity = EntityTest::create();
|
||||
|
|
|
@ -8,11 +8,18 @@ use WebDriver\Service\CurlService;
|
|||
use WebDriver\Exception\CurlExec;
|
||||
use WebDriver\Exception as WebDriverException;
|
||||
|
||||
@trigger_error('The \Drupal\FunctionalJavascriptTests\WebDriverCurlService class is deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. There is no replacement. See https://www.drupal.org/node/3462152', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Provides a curl service to interact with Selenium driver.
|
||||
*
|
||||
* Extends WebDriver\Service\CurlService to solve problem with race conditions,
|
||||
* when multiple processes requests.
|
||||
*
|
||||
* @deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. There is
|
||||
* no replacement, use the base class instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3462152
|
||||
*/
|
||||
class WebDriverCurlService extends CurlService {
|
||||
|
||||
|
|
|
@ -34,9 +34,14 @@ exports.command = function drupalCreateRole(
|
|||
.to.be.visible.before(2000);
|
||||
|
||||
machineName = await this.getText('.user-role-form .machine-name-value');
|
||||
this.submitForm('#user-role-form');
|
||||
this.submitForm('#user-role-form').assert.textContains(
|
||||
'[data-drupal-messages]',
|
||||
`Role ${roleName} has been added.`,
|
||||
);
|
||||
|
||||
this.drupalRelativeURL('/admin/people/permissions');
|
||||
this.drupalRelativeURL('/admin/people/permissions').waitForElementVisible(
|
||||
'table.permissions',
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
permissions.map(async (permission) =>
|
||||
|
@ -44,9 +49,10 @@ exports.command = function drupalCreateRole(
|
|||
),
|
||||
);
|
||||
|
||||
this.submitForm('#user-admin-permissions');
|
||||
|
||||
this.drupalRelativeURL('/admin/people/permissions');
|
||||
this.submitForm('#user-admin-permissions').assert.textContains(
|
||||
'[data-drupal-messages]',
|
||||
'The changes have been saved.',
|
||||
);
|
||||
}).perform(() => {
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(self, machineName);
|
||||
|
|
|
@ -19,10 +19,9 @@ module.exports = {
|
|||
.drupalRelativeURL('/node')
|
||||
.assert.not.visible(buttonSelector)
|
||||
.assert.attributeEquals(buttonSelector, 'aria-checked', 'false')
|
||||
.getLocationInView('footer.site-footer', () => {
|
||||
browser.assert.visible(buttonSelector);
|
||||
browser.assert.not.visible('#site-header__inner');
|
||||
})
|
||||
.click('.block-system-powered-by-block .drupal-logo')
|
||||
.assert.visible(buttonSelector)
|
||||
.assert.not.visible('#site-header__inner')
|
||||
.assert.not.visible(mainMenuSelector)
|
||||
.click(buttonSelector)
|
||||
.assert.visible(mainMenuSelector)
|
||||
|
|
|
@ -68,7 +68,7 @@ module.exports = {
|
|||
browserName: 'chrome',
|
||||
acceptSslCerts: true,
|
||||
'goog:chromeOptions': {
|
||||
w3c: false,
|
||||
w3c: !!process.env.DRUPAL_TEST_WEBDRIVER_W3C,
|
||||
args: process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS
|
||||
? process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS.split(' ')
|
||||
: [],
|
||||
|
@ -95,7 +95,7 @@ module.exports = {
|
|||
browserName: 'chrome',
|
||||
acceptSslCerts: true,
|
||||
'goog:chromeOptions': {
|
||||
w3c: false,
|
||||
w3c: !!process.env.DRUPAL_TEST_WEBDRIVER_W3C,
|
||||
args: process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS
|
||||
? process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS.split(' ')
|
||||
: [],
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace Drupal\Tests;
|
|||
use Behat\Mink\Driver\BrowserKitDriver;
|
||||
use Behat\Mink\Element\Element;
|
||||
use Behat\Mink\Element\TraversableElement;
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverCurlService;
|
||||
use WebDriver\Exception;
|
||||
|
||||
/**
|
||||
|
@ -93,7 +92,6 @@ class DocumentElement extends TraversableElement {
|
|||
*/
|
||||
public function waitFor($timeout, $callback) {
|
||||
// Wraps waits in a function to catch curl exceptions to continue waiting.
|
||||
WebDriverCurlService::disableRetry();
|
||||
$count = 0;
|
||||
$wrapper = function (Element $element) use ($callback, &$count) {
|
||||
$count++;
|
||||
|
@ -111,7 +109,6 @@ class DocumentElement extends TraversableElement {
|
|||
// page state has probably changed while the callback is running.
|
||||
return call_user_func($callback, $this);
|
||||
}
|
||||
WebDriverCurlService::enableRetry();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue