0

Trying to run some functional JS tests, Anyone know what is up here?

Runtime:       PHP 7.1.33
Configuration: /app/phpunit.xml

Testing Drupal\Tests\commerce_product\FunctionalJavascript\ProductAttributeJavascriptTest
Test 'Drupal\Tests\commerce_product\FunctionalJavascript\ProductAttributeJavascriptTest::testProductAttributeValues' started
Test 'Drupal\Tests\commerce_product\FunctionalJavascript\ProductAttributeJavascriptTest::testProductAttributeValues' ended

//

1) Drupal\Tests\commerce_product\FunctionalJavascript\ProductAttributeJavascriptTest::testProductAttributeValues
Behat\Mink\Exception\ElementNotFoundException: Button with id|name|label|value "Log in" not found.

/app/web/core/tests/Drupal/Tests/WebAssert.php:77
/app/web/core/tests/Drupal/Tests/UiHelperTrait.php:77
/app/web/core/tests/Drupal/Tests/UiHelperTrait.php:250
/app/web/modules/contrib/commerce/tests/src/FunctionalJavascript/CommerceWebDriverTestBase.php:87
/app/web/modules/contrib/commerce/modules/product/tests/src/FunctionalJavascript/ProductWebDriverTestBase.php:60

There is an HTML output that works and has a log in button with value = "Log in" I can supply the .lando || phpunit.xml if that helps.

Output page :

<hr />ID #9 (<a href="Drupal_Tests_commerce_product_FunctionalJavascript_ProductAttributeJavascriptTest-8-36295254.html">Previous</a> | <a href="Drupal_Tests_commerce_product_FunctionalJavascript_ProductAttributeJavascriptTest-10-36295254.html">Next</a>)<hr />GET request to: http://drupal-orange-project.lndo.site/user/login<hr />Ending URL: http://drupal-orange-project.lndo.site/user/login<hr /><html lang="en" dir="ltr" class=" js"><head>
    <meta charset="utf-8">
<meta name="Generator" content="Drupal 8 (https://www.drupal.org)">
<meta name="MobileOptimized" content="width">
<meta name="HandheldFriendly" content="true">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="/core/misc/favicon.ico" type="image/vnd.microsoft.icon">

    <title>Log in | Drupal</title>
    <link rel="stylesheet" media="all" href="/core/modules/system/css/components/ajax-progress.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/align.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/autocomplete-loading.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/fieldgroup.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/container-inline.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/clearfix.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/details.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/hidden.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/item-list.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/js.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/nowrap.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/position-container.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/progress.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/reset-appearance.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/resize.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/sticky-header.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/system-status-counter.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/system-status-report-counters.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/system-status-report-general-info.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/tabledrag.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/tablesort.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/css/components/tree-child.module.css?q4jmda">
<link rel="stylesheet" media="all" href="/core/modules/system/tests/modules/css_disable_transitions_test/css/disable_transitions.theme.css?q4jmda">


<!--[if lte IE 8]>
<script src="/core/assets/vendor/html5shiv/html5shiv.min.js?v=3.7.3"></script>
<![endif]-->

  </head>
  <body>
        <a href="#main-content" class="visually-hidden focusable">
      Skip to main content
    </a>

      <div class="dialog-off-canvas-main-canvas" data-off-canvas-main-canvas="">
    <div class="layout-container">

  <header role="banner">

  </header>










  <main role="main">
    <a id="main-content" tabindex="-1"></a>
    <div class="layout-content">
        <div>
    <div data-drupal-messages-fallback="" class="hidden"></div><form class="user-login-form" data-drupal-selector="user-login-form" action="/user/login" method="post" id="user-login-form" accept-charset="UTF-8">
  <div class="js-form-item form-item js-form-type-textfield form-item-name js-form-item-name">
      <label for="edit-name" class="js-form-required form-required">Username</label>
        <input autocorrect="none" autocapitalize="none" spellcheck="false" autofocus="autofocus" data-drupal-selector="edit-name" aria-describedby="edit-name--description" type="text" id="edit-name" name="name" value="" size="60" maxlength="60" class="form-text required" required="required" aria-required="true">

            <div id="edit-name--description" class="description">
      Enter your Drupal username.
    </div>
  </div>
<div class="js-form-item form-item js-form-type-password form-item-pass js-form-item-pass">
      <label for="edit-pass" class="js-form-required form-required">Password</label>
        <input data-drupal-selector="edit-pass" aria-describedby="edit-pass--description" type="password" id="edit-pass" name="pass" size="60" maxlength="128" class="form-text required" required="required" aria-required="true">

            <div id="edit-pass--description" class="description">
      Enter the password that accompanies your username.
    </div>
  </div>
<input autocomplete="off" data-drupal-selector="form-myrmxvb4c2hhvtvec5t9ozbmf4d7sx7xyzocl7jjk88" type="hidden" name="form_build_id" value="form-MyRMXVb4C2hhvtVec5T9oZbmf4D7SX7XYzoCL7JJK88">
<input data-drupal-selector="edit-user-login-form" type="hidden" name="form_id" value="user_login_form">
<div data-drupal-selector="edit-actions" class="form-actions js-form-wrapper form-wrapper" id="edit-actions"><input data-drupal-selector="edit-submit" type="submit" id="edit-submit" name="op" value="Log in" class="button js-form-submit form-submit">
</div>

</form>

  </div>

    </div>
          <aside class="layout-sidebar-first" role="complementary">
          <div>
    <div id="block-fbgd5hmx">



  <h1>Log in</h1>


  </div>
<div id="block-zncqsq6z">


        <h2 class="visually-hidden">Primary tabs</h2>
  <ul><li><a href="/user/login" data-drupal-link-system-path="user/login" class="is-active">Log in<span class="visually-hidden">(active tab)</span></a></li>
<li><a href="/user/register" data-drupal-link-system-path="user/register">Create new account</a></li>
<li><a href="/user/password" data-drupal-link-system-path="user/password">Reset your password</a></li>
</ul>

  </div>

  </div>

      </aside>


  </main>


</div>
  </div>


    <script type="application/json" data-drupal-selector="drupal-settings-json">{"path":{"baseUrl":"\/","scriptPath":null,"pathPrefix":"","currentPath":"user\/login","currentPathIsAdmin":false,"isFront":true,"currentLanguage":"en"},"pluralDelimiter":"\u0003","suppressDeprecationErrors":false,"ajaxTrustedUrl":{"form_action_p_pvdeGsVG5zNF_XLGPTvYSKCf43t8qZYSwcfZl2uzM":true},"user":{"uid":0,"permissionsHash":"59b0d4b8256570a057e21f4ac353f2481743b37a6aca5e0126c010e2958d98f3"}}</script>
<script src="/core/modules/system/tests/modules/js_deprecation_log_test/js/js_deprecation_log.js?v=8.8.1"></script>
<script src="/core/misc/drupalSettingsLoader.js?v=8.8.1"></script>
<script src="/core/misc/drupal.js?v=8.8.1"></script>
<script src="/core/misc/drupal.init.js?v=8.8.1"></script>
<script src="/core/modules/system/tests/modules/css_disable_transitions_test/js/disable_transitions.theme.js?v=8.8.1"></script>



</body></html>

.lando.yml

name: drupal-orange-project
recipe: drupal8
config:

  # php - Optional - Default is latest php supported by Drupal 8.
  # See: https://www.drupal.org/docs/8/system-requirements/php-requirements
  php: '7.2'

  # nginx - Optional - Default Apache
  # See: https://www.drupal.org/docs/7/system-requirements/web-server
  via: nginx

  # DataBase - Optional - Default latest mysql.
  # database: mysql
  #   type: 8

  # webroot - Optional - Location of webroot relative to your approot.
  # If ommitted this will be your approot itself.
  webroot: web

  # xdebug - Optional
  # If you are having trouble getting xdebug to work please see:
  # https://docs.devwithlando.io/services/php.html#using-xdebug
  xdebug: true


services:

  # Solr default version 7.1
  # Supported Versions: https://docs.devwithlando.io/services/solr.html
  index:
    type: solr

    # Optionally declare the name of the solr core.
    core: orange_solr

    # Dynamically assign a port each time you start your app
    portforward: true 

    # Optionally use custom solr config files eg (schema.xml and solrconfig.xml)
    # This is helpful if frameworks require custom config eg Drupal.
    # This is relative to the app root (may be different from your webroot).
    config:
      conf: web/modules/contrib/search_api_solr/solr-conf/7.x


  # node default version 8.9 
  # https://docs.devwithlando.io/services/node.html
  node:
    type: node
    run: 
      # Installs all requirements for orange_framework/gulpfile.js
      # This should probably be done in a package.json and package.lock in the orange_framework
      - cd $LANDO_MOUNT
      - npm install gulp gulp-sass gulp-sourcemaps gulp-rename 
      - npm install gulp-postcss postcss-easysprites autoprefixer gulp-cli


  mailhog: 
    type: mailhog
    hogfrom:
      - appserver
    portforward: true

  webdriver:
    type: compose
    services:
      image: selenium/standalone-chrome
      user: root
      ports:
        - "4444:4444"
      volumes:
        - /dev/shm:/dev/shm
      command: /opt/bin/entry_point.sh

proxy:
  index:
    - solr.drupal-orange-project.lndo.site:8983

  mailhog:
    - mail.drupal-orange-project.lndo.site


tooling:
  node:
   service: node
  npm:
    service: node
  gulp:
    service: node

3
  • I sometimes run into a similar issue when running tests with docker (either using docker natively or docker+ solutions like lando or ddev), and I have no clue why the test runner simply fails to output anything. I'm not sure there's anything to work with here for an answer, but maybe try to provide more details regarding the web container used by lando.
    – mradcliffe
    Commented Jan 24, 2020 at 13:45
  • I have ran into this before, it could be that the test runner has no access to the docker container or the error is not really the one output. Having a screenshot and dump of the page HTML the test is looking at would help.
    – Kevin
    Commented Jan 24, 2020 at 14:58
  • Alright, add the .lando.yml and the output html page. Does this help reveal anything?
    – Derek C.
    Commented Jan 24, 2020 at 21:47

1 Answer 1

1

Here's what I've found after being annoyed about this over and over again.

  1. SIMPLETEST_BASE_URL should be set to a URL that is resolvable from where phpunit is run.

    • Inside a container, the hostname should match the name of the container where nginx or apache is running e.g. http://apache or http://nginx or whatever lando uses (look up the name using docker ps and isolate the service name from docker-compose).
    • Outside a container, the hostname should match the resolvable URL e.g. http://web.internal.
  2. I additionally had issues on my own docker-compose setup running traefik with a http to https redirect using self-signed certificates. But even though I disabled these, used a http address, hacked the /etc/hosts files in all the containers, I was not able to work around the issue.

My work around currently is to run tests inside the container using phpunit. This is far from ideal as I cannot run from my IDE, but at least it's working for me.

1
  • 1
    I wound up solving this recently using a second front label for the apache container, and a network alias for the same local domain so http://apache was not needed and instead resolved without it. Not a great solution, but using apache bugs me and is hard to spot whats going on at first.
    – Kevin
    Commented Feb 26, 2020 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.