Code Duplication    Length = 17-17 lines in 2 locations

src/DrupalExtension/Traits/Generic.php 2 locations

@@ 38-54 (lines=17) @@
35
   *
36
   * @Then I should see the field :field
37
   */
38
  public function iShouldSeeTheField($field) {
39
    $element = $this->getSession()->getPage();
40
    $result = $element->findField($field);
41
    try {
42
      if ($result && !$result->isVisible()) {
43
        throw new \Exception(sprintf("No field '%s' on the page %s", $field, $this->getSession()->getCurrentUrl()));
44
      }
45
    }
46
    catch (UnsupportedDriverActionException $e) {
47
      // We catch the UnsupportedDriverActionException exception in case
48
      // this step is not being performed by a driver that supports javascript.
49
      // All other exceptions are valid.
50
    }
51
    if (empty($result)) {
52
      throw new \Exception(sprintf("No field '%s' on the page %s", $field, $this->getSession()->getCurrentUrl()));
53
    }
54
  }
55
56
  /**
57
   * Assert absence of given field.
@@ 61-77 (lines=17) @@
58
   *
59
   * @Then I should not see the field :field
60
   */
61
  public function iShouldNotSeeTheField($field) {
62
    $element = $this->getSession()->getPage();
63
    $result = $element->findField($field);
64
    try {
65
      if ($result && $result->isVisible()) {
66
        throw new \Exception(sprintf("The field '%s' was present on the page %s and was not supposed to be", $field, $this->getSession()->getCurrentUrl()));
67
      }
68
    }
69
    catch (UnsupportedDriverActionException $e) {
70
      // We catch the UnsupportedDriverActionException exception in case
71
      // this step is not being performed by a driver that supports javascript.
72
      // All other exceptions are valid.
73
      if ($result) {
74
        throw new \Exception(sprintf("The field '%s' was present on the page %s and was not supposed to be", $field, $this->getSession()->getCurrentUrl()));
75
      }
76
    }
77
  }
78
79
  /**
80
   * Visit taxonomy term page given its type and name.