BTB has a clickLink() function and it works the same as WTB's as long as it is called without a second parameter. When the second parameter is used however the wrong link will be clicked after converting to BTB because the parameter will be ignored.

The second parameter is $index and it's used to specify which link should be clicked when there is more than one with the same text.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jmuzz created an issue. See original summary.

jmuzz’s picture

jmuzz’s picture

The last submitted patch, 2: btb-clicklink_argument-2797943-2-tests_only.patch, failed testing.

dawehner’s picture

The tests look great!

+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -1615,10 +1615,18 @@ protected function cssSelect($selector) {
+  protected function clickLink($label, $index = NULL) {
...
+    if (is_integer($index)) {
+      $links = $this->getSession()->getPage()->findAll('named', array('link', $label));
+      $links[$index]->click();
+    }
+    else {
+      $this->getSession()->getPage()->clickLink($label);
+    }
   }

What about simplifying this code a bit and use $index = 0 by default and then get rid of the if condition and else codepart?

claudiu.cristea’s picture

Version: 8.3.x-dev » 8.2.x-dev
Category: Task » Bug report
FileSize
1.14 KB
3.02 KB

This is a regression from WebTestBase, so it's a bug. For this reason it should go in 8.2.x as well.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for simplifying the code!

  • catch committed fec70c8 on 8.3.x
    Issue #2797943 by jmuzz, claudiu.cristea, dawehner: Add support for...

  • catch committed 1822314 on 8.2.x
    Issue #2797943 by jmuzz, claudiu.cristea, dawehner: Add support for...
catch’s picture

Status: Reviewed & tested by the community » Fixed

This is a test improvement (borderline bug/regression) so eligible during rc.

Committed/pushed to 8.3.x and cherry-picked to 8.2.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.