Exemplo n.º 1
0
 public function validarPaginaIcialValidarMensagemAlerta()
 {
     $this->driver->get($this->url);
     $this->driver->findElement(WebDriverBy::id("novopedido"))->click();
     $this->driver->findElement(WebDriverBy::id("id"))->sendKeys("TESTE");
     $combo = $this->driver->findElement(WebDriverBy::id("produto"));
     $combo = new WebDriverSelect($combo);
     $combo->selectByValue("Firefox");
     $this->driver->findElement(WebDriverBy::id("estoque"))->sendKeys(100);
     $this->driver->findElement(WebDriverBy::id("valor"))->sendKeys(19.9);
     $this->driver->findElement(WebDriverBy::cssSelector("label[for='quantidade5']"))->click();
     $this->driver->findElement(WebDriverBy::tagName("button"))->click();
     $mensagem = $this->driver->switchTo()->alert()->getText();
     $this->driver->switchTo()->alert()->dismiss();
     $this->assertEquals("Sucesso", $mensagem);
 }
Exemplo n.º 2
0
 /**
  * Append text to an element
  * Can add another selection to a select box
  *
  * ``` php
  * <?php
  * $I->appendField('#mySelectbox', 'SelectValue');
  * $I->appendField('#myTextField', 'appended');
  * ?>
  * ```
  *
  * @param string $field
  * @param string $value
  * @throws \Codeception\Exception\ElementNotFound
  */
 public function appendField($field, $value)
 {
     $el = $this->findField($field);
     switch ($el->getTagName()) {
         //Multiple select
         case "select":
             $matched = false;
             $wdSelect = new \WebDriverSelect($el);
             try {
                 $wdSelect->selectByVisibleText($value);
                 $matched = true;
             } catch (\NoSuchElementException $e) {
             }
             try {
                 $wdSelect->selectByValue($value);
                 $matched = true;
             } catch (\NoSuchElementException $e) {
             }
             if ($matched) {
                 return;
             }
             throw new ElementNotFound(json_encode($value), "Option inside {$field} matched by name or value");
             break;
         case "textarea":
             $el->sendKeys($value);
             return;
             break;
             //Text, Checkbox, Radio
         //Text, Checkbox, Radio
         case "input":
             $type = $el->getAttribute('type');
             if ($type == 'checkbox') {
                 //Find by value or css,id,xpath
                 $field = $this->findCheckable($this->webDriver, $value, true);
                 if (!$field) {
                     throw new ElementNotFound($value, "Checkbox or Radio by Label or CSS or XPath");
                 }
                 if ($field->isSelected()) {
                     return;
                 }
                 $field->click();
                 return;
             } elseif ($type == 'radio') {
                 $this->selectOption($field, $value);
                 return;
             } else {
                 $el->sendKeys($value);
                 return;
             }
             break;
         default:
     }
     throw new ElementNotFound($field, "Field by name, label, CSS or XPath");
 }
Exemplo n.º 3
0
 /**
  * @param $url
  */
 public function applicationGroupProfiles($url)
 {
     $this->webDriver->get($url . 'program/groups');
     $this->webDriver->findElement(WebDriverBy::id('edit-button'))->click();
     $this->webDriver->findElement(WebDriverBy::id('edit-field-group-name-und-0-value'))->sendKeys('Group 1');
     $this->webDriver->findElement(WebDriverBy::id('edit-field-total-children-und-0-value'))->sendKeys('10');
     $this->webDriver->findElement(WebDriverBy::id('edit-field-children-age-category-und-3'))->click();
     $selectMSH = new WebDriverSelect($this->webDriver->findElement(WebDriverBy::id('edit-field-group-schedule-und-2-starthours-hours')));
     $selectMSH->selectByValue('6');
     $selectMSM = new WebDriverSelect($this->webDriver->findElement(WebDriverBy::id('edit-field-group-schedule-und-2-starthours-minutes')));
     $selectMSM->selectByValue('00');
     $selectMSA = new WebDriverSelect($this->webDriver->findElement(WebDriverBy::id('edit-field-group-schedule-und-2-starthours-ampm')));
     $selectMSA->selectByValue('am');
     $selectMEH = new WebDriverSelect($this->webDriver->findElement(WebDriverBy::id('edit-field-group-schedule-und-2-endhours-hours')));
     $selectMEH->selectByValue('6');
     $selectMEM = new WebDriverSelect($this->webDriver->findElement(WebDriverBy::id('edit-field-group-schedule-und-2-endhours-minutes')));
     $selectMEM->selectByValue('00');
     $selectMEA = new WebDriverSelect($this->webDriver->findElement(WebDriverBy::id('edit-field-group-schedule-und-2-endhours-ampm')));
     $selectMEA->selectByValue('pm');
     $this->webDriver->findElement(WebDriverBy::id('edit-submit'))->click();
 }