Code Duplication    Length = 17-17 lines in 2 locations

src/DrupalExtension/Traits/Generic.php 2 locations

@@ 226-242 (lines=17) @@
223
   *
224
   * @Then I should see the field :field
225
   */
226
  public function iShouldSeeTheField($field) {
227
    $element = $this->getSession()->getPage();
228
    $result = $element->findField($field);
229
    try {
230
      if ($result && !$result->isVisible()) {
231
        throw new \Exception(sprintf("No field '%s' on the page %s", $field, $this->getSession()->getCurrentUrl()));
232
      }
233
    }
234
    catch (UnsupportedDriverActionException $e) {
235
      // We catch the UnsupportedDriverActionException exception in case
236
      // this step is not being performed by a driver that supports javascript.
237
      // All other exceptions are valid.
238
    }
239
    if (empty($result)) {
240
      throw new \Exception(sprintf("No field '%s' on the page %s", $field, $this->getSession()->getCurrentUrl()));
241
    }
242
  }
243
244
  /**
245
   * Assert absence of given field.
@@ 249-265 (lines=17) @@
246
   *
247
   * @Then I should not see the field :field
248
   */
249
  public function iShouldNotSeeTheField($field) {
250
    $element = $this->getSession()->getPage();
251
    $result = $element->findField($field);
252
    try {
253
      if ($result && $result->isVisible()) {
254
        throw new \Exception(sprintf("The field '%s' was present on the page %s and was not supposed to be", $field, $this->getSession()->getCurrentUrl()));
255
      }
256
    }
257
    catch (UnsupportedDriverActionException $e) {
258
      // We catch the UnsupportedDriverActionException exception in case
259
      // this step is not being performed by a driver that supports javascript.
260
      // All other exceptions are valid.
261
      if ($result) {
262
        throw new \Exception(sprintf("The field '%s' was present on the page %s and was not supposed to be", $field, $this->getSession()->getCurrentUrl()));
263
      }
264
    }
265
  }
266
267
  /**
268
   * Visit taxonomy term page given its type and name.