/**
  * Upload file inside entity browser.
  *
  * NOTE: It will search for first tab with upload widget and file will be
  * uploaded there. Upload is done over input file field and it has to be
  * visible for selenium to work.
  *
  * @param \Behat\Mink\Element\DocumentElement $page
  *   Current active page.
  * @param string $filePath
  *   Path to file that should be uploaded.
  *
  * @throws \Exception
  */
 public function uploadFile(DocumentElement $page, $filePath)
 {
     // Click all tabs until we find upload Tab.
     $tabLinks = $page->findAll('css', '.eb-tabs a');
     if (empty($tabLinks)) {
         throw new \Exception(sprintf('Unable to find tabs in entity browser iframe on page %s', $this->getSession()->getCurrentUrl()));
     }
     // Click all tabs until input file field for upload is found.
     $fileFieldSelector = "input[type='file'].dz-hidden-input";
     $fileField = NULL;
     foreach ($tabLinks as $tabLink) {
         /* @var \Behat\Mink\Element\NodeElement $tabLink */
         $tabLink->click();
         $this->assertSession()->assertWaitOnAjaxRequest();
         $fileField = $page->find('css', $fileFieldSelector);
         if (!empty($fileField)) {
             break;
         }
     }
     if (empty($fileField)) {
         throw new \Exception(sprintf('The drop-down file field was not found on the page %s', $this->getSession()->getCurrentUrl()));
     }
     // Make file field visible and isolate possible problems with "multiple".
     $this->getSession()->executeScript('jQuery("' . $fileFieldSelector . '").show(0).css("visibility","visible").width(200).height(30).removeAttr("multiple");');
     $fileField->attachFile($filePath);
     $this->assertSession()->assertWaitOnAjaxRequest();
     // Wait up to 10 sec that "Use selected" button is active.
     $this->getSession()->wait(10000, '(typeof jQuery === "undefined" || !jQuery(\'input[name="op"]\').is(":disabled"))');
     $this->assertSession()->assertWaitOnAjaxRequest();
 }
 /**
  * Set meta tag value for group of checkboxes.
  *
  * Existing selection will be cleared before new values are applied.
  *
  * @param \Behat\Mink\Element\DocumentElement $page
  *   Current active page.
  * @param string $fieldName
  *   Field name.
  * @param string $value
  *   Comma separated values for meta tag checkboxes.
  */
 protected function setCheckboxMetaTag(DocumentElement $page, $fieldName, $value)
 {
     // UnCheck all checkboxes and check defined.
     $this->getSession()->executeScript("jQuery('input[name*=\"{$fieldName}\"]').prop('checked', false);");
     $checkNames = explode(',', $value);
     foreach ($checkNames as $checkName) {
         $checkBoxName = $fieldName . '[' . trim($checkName) . ']';
         $this->scrollElementInView('[name="' . $checkBoxName . '"]');
         $page->checkField($checkBoxName);
     }
 }
 /**
  * @covers ::assertNoUniqueText
  */
 public function testAssertNoUniqueTextMarkup()
 {
     $this->page->getText()->willReturn('foo bar bar');
     $markupObject = $this->prophesize(MarkupInterface::class);
     $markupObject->__toString()->willReturn('bar');
     $this->assertNoUniqueText($markupObject->reveal());
 }
 /**
  * Select value in choice list
  *
  * @param DocumentElement $page
  * @param string          $component
  * @param string          $field
  * @param string          $value
  * @throws \Exception
  */
 private function selectComponentValue(DocumentElement $page, $component, $field, $value)
 {
     $select = $page->find('css', sprintf('#%s', $field));
     if (!$select) {
         throw new \Exception(sprintf('No select "%s" found', $field));
     }
     $selector = sprintf('.fs-%1$s button.fs-%1$s-item', $component);
     $choices = $page->findAll('css', $selector);
     foreach ($choices as $choice) {
         if ($choice->getText() == $value) {
             $choice->click();
             return;
         }
     }
     throw new \Exception(sprintf('Value "%s" not found for "%s"', $value, $field));
 }
Ejemplo n.º 5
0
 /**
  * Get a html element by css selector notation
  * @param string $cssSelector the css selector path
  * @return mixed
  * @throws Behat\Mink\Exception\ElementNotFoundException
  */
 public function objectByCssSelector($cssSelector)
 {
     $element = $this->page->find('css', $cssSelector);
     try {
         if ($element == null) {
             // @todo: add cloudrexx exception
             throw new \Behat\Mink\Exception\ElementNotFoundException($this->session, 'input', 'css', 'input[type="submit"]');
         }
     } catch (Exception $e) {
         echo $e->getLine();
     }
     return $element;
 }
 /**
  * Fill CKEditor field.
  *
  * @param \Behat\Mink\Element\DocumentElement $page
  *   Current active page.
  * @param string $ckEditorCssSelector
  *   CSS selector for CKEditor.
  * @param string $text
  *   Text that will be filled into CKEditor.
  */
 public function fillCkEditor(DocumentElement $page, $ckEditorCssSelector, $text)
 {
     $ckEditor = $page->find('css', $ckEditorCssSelector);
     $ckEditorId = $ckEditor->getAttribute('id');
     $this->getSession()->getDriver()->executeScript("CKEDITOR.instances[\"{$ckEditorId}\"].setData(\"{$text}\");");
 }
Ejemplo n.º 7
0
 /**
  * @param DocumentElement $page
  * @param string $collectionName
  *
  * @return NodeElement
  */
 protected function getFormCollectionDiv(DocumentElement $page, $collectionName)
 {
     return $page->find('css', 'div[data-form-type="collection"][id*="' . $collectionName . '"]');
 }
Ejemplo n.º 8
0
 public function testGetOuterHtml()
 {
     $expects = 'val1';
     $this->driver->expects($this->once())->method('getOuterHtml')->with('//html')->will($this->returnValue($expects));
     $this->assertEquals($expects, $this->document->getOuterHtml());
 }
 /**
  * Select value in choice list
  *
  * @param DocumentElement $page
  * @param string          $field
  * @param string          $value
  * @throws \Exception
  */
 private function selectValue(DocumentElement $page, $field, $value)
 {
     $chosenResults = $page->findAll('css', '.select2-results li');
     foreach ($chosenResults as $result) {
         if ($result->getText() == $value) {
             $result->click();
             return;
         }
     }
     throw new \Exception(sprintf('Value "%s" not found for "%s"', $value, $field));
 }
Ejemplo n.º 10
0
 /**
  * Initialize the page.
  *
  * @param IPageFactory $page_factory Page factory.
  */
 public function __construct(IPageFactory $page_factory)
 {
     parent::__construct($page_factory->getSession());
     $this->pageFactory = $page_factory;
     $this->pageFactory->initPage($this)->initElements($this, $this->pageFactory->createDecorator($this));
 }
Ejemplo n.º 11
0
 /**
  * @param Session $session
  * @param Factory $factory
  * @param array   $parameters
  */
 public function __construct(Session $session, Factory $factory, array $parameters = array())
 {
     parent::__construct($session);
     $this->factory = $factory;
     $this->parameters = $parameters;
 }
 /**
  * Click button for editing of paragraph.
  *
  * @param \Behat\Mink\Element\DocumentElement $page
  *   Current active page.
  * @param string $paragraphsFieldName
  *   Field name in content type used to paragraphs.
  * @param int $index
  *   Index of paragraph to be edited, starts from 0.
  */
 public function editParagraph(DocumentElement $page, $paragraphsFieldName, $index)
 {
     $editButtonName = "{$paragraphsFieldName}_{$index}_edit";
     $this->scrollElementInView("[name=\"{$editButtonName}\"]");
     $page->pressButton($editButtonName);
     $this->assertSession()->assertWaitOnAjaxRequest();
 }