Ejemplo n.º 1
0
 /**
  * @param RawTqContext $context
  *   Behat context.
  * @param string $selector
  *   Element selector.
  * @param string $date
  *   Human-readable date.
  */
 public function __construct(RawTqContext $context, $selector, $date)
 {
     $this->context = $context;
     if (null === $this->execute('$.fn.datepicker')) {
         throw new \RuntimeException('jQuery DatePicker is not available on the page.');
     }
     $this->element = $this->context->element('*', $selector);
     $this->date = sprintf("new Date('%s')", date('c', strtotime($date)));
 }
Ejemplo n.º 2
0
 /**
  * @param RawTqContext $context
  *   Behat context.
  * @param string $selector
  *   Field selector.
  * @param bool $not
  *   Negate the condition.
  * @param string $expected
  *   Expected value.
  */
 public function __construct(RawTqContext $context, $selector, $not, $expected = '')
 {
     $this->not = (bool) $not;
     $this->context = $context;
     $this->selector = $selector;
     $this->expected = $expected;
     $this->element = $this->context->element('field', $selector);
     $this->value = $this->element->getValue();
     $this->tag = $this->element->getTagName();
 }
Ejemplo n.º 3
0
 /**
  * Get the editor instance for use in Javascript.
  *
  * @param string $selector
  *   Any selector of a form field.
  *
  * @throws \RuntimeException
  * @throws \Exception
  * @throws \WebDriver\Exception\NoSuchElement
  *
  * @return string
  *   A Javascript expression that representing WYSIWYG instance.
  */
 protected function getInstance($selector = '')
 {
     if (empty($this->object)) {
         throw new \RuntimeException('Editor instance was not set.');
     }
     if (empty($this->selector) && empty($selector)) {
         throw new \RuntimeException('No such editor was not selected.');
     }
     $this->setSelector($selector);
     if (empty($this->instances[$this->selector])) {
         $instanceId = $this->context->element('field', $this->selector)->getAttribute('id');
         $instance = sprintf($this->object, $instanceId);
         if (!$this->context->executeJs("return !!{$instance}")) {
             throw new \Exception(sprintf('Editor "%s" was not found.', $instanceId));
         }
         $this->instances[$this->selector] = $instance;
     }
     return $this->instances[$this->selector];
 }