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); }
/** * Tests that Add examiner section, insert an Examiner and find it. * * @return void */ function testExaminerAddExaminer() { //insert a new exmainer with name "Test_Examiner" and radiologist //in the TEST_Site. $this->safeGet($this->url . "/examiner/"); $this->safeFindElement(WebDriverBy::Name("addName"))->sendKeys("Test_Examiner"); $this->safeFindElement(WebDriverBy::Name("addRadiologist"))->click(); $select = $this->safeFindElement(WebDriverBy::Name("addSite")); $element = new WebDriverSelect($select); $element->selectByVisibleText("TEST_Site"); $bodyText = $this->safeFindElement(WebDriverBy::Name("fire_away"))->click(); sleep(5); //search the examiner which inserted $this->webDriver->findElement(WebDriverBy::Name("examiner"))->sendKeys("Test_Examiner"); $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); $bodyText = $this->safeFindElement(WebDriverBy::cssSelector("body"))->getText(); $this->assertContains("Test_Examiner", $bodyText); }
/** * 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"); }
/** * Performs a candidate search using the specified criteria and verifies * the candidates obtained. * * @param array $criteria criteria for the search. * @param string $expectedResults the candidates that should be returned. * * @return void. */ private function _assertSearchBy(array $criteria, $expectedResults) { foreach ($criteria as $elementName => $elementValue) { $element = $this->webDriver->findElement(WebDriverBy::Name($elementName)); switch ($element->getTagName()) { case 'input': $element->clear(); $element->sendKeys($elementValue); break; case 'select': $selectElement = new WebDriverSelect($element); $selectElement->selectByVisibleText($elementValue); break; default: throw Exception('Element type ' . $element->getTagName() . ' not supported'); } } $showDataButton = $this->webDriver->findElement(WebDriverBy::Id("showdata_advanced_options")); $showDataButton->click(); $this->_assertCandidateTableContents('datatable', $expectedResults); }
/** * Assert that the password has a specific permission for a target user * @param $password * @param $username * @param $permissionType * @param $options */ public function assertPermission($password, $username, $permissionType, $options = array()) { $this->gotoSharePassword($password['id']); // I can see the user has a direct permission $this->assertElementContainsText($this->findByCss('#js_permissions_list'), $username); // Find the permission row element $rowElement = $this->findByXpath('//*[@id="js_permissions_list"]//*[.="' . $username . '"]//ancestor::li[1]'); // I can see the permission is as expected $select = new WebDriverSelect($rowElement->findElement(WebDriverBy::cssSelector('.js_share_rs_perm_type'))); $this->assertEquals($permissionType, $select->getFirstSelectedOption()->getText()); // Close the dialog if (!isset($options['closeDialog']) || $options['closeDialog'] == true) { $this->find('.dialog .dialog-close')->click(); } }
/** * @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(); }
/** * Tests that, upload function in document_repository module * * @return void */ function testDocumentRepositoryUploadFileEditDeleteComment() { $this->markTestSkipped("This method isn't working properly on travis."); $this->safeGet($this->url . "/document_repository/"); $this->safeFindElement(WebDriverBy::Xpath("//*[@id='TESTTESTTESTTESTa']/td/span"))->click(); $this->safeFindElement(WebDriverBy::Id("9999999"))->click(); // modify comment,search it and check it $select = $this->safeFindElement(WebDriverBy::Id("categoryEdit")); $element = new WebDriverSelect($select); $element->selectByVisibleText("TESTTESTTESTTEST"); $site = $this->safeFindElement(WebDriverBy::Id("siteEdit")); $elementSite = new WebDriverSelect($site); $elementSite->selectByVisibleText("Any"); $this->safeFindElement(WebDriverBy::Id("commentsEdit"))->sendKeys("This is a test comment!"); $this->safeFindElement(WebDriverBy::Id("postEdit"))->click(); sleep(5); $this->safeFindElement(WebDriverBy::Name("File_name"))->sendKeys("README.md"); $this->safeFindElement(WebDriverBy::Name("filter"))->click(); $text = $this->safeFindElement(WebDriverBy::cssSelector("#dir-tree > tr"), 3000)->getText(); $this->assertContains("This is a test comment!", $text); // delete upload file $this->safeFindElement(WebDriverBy::linkText("Delete"), 3000)->click(); $this->safeFindElement(WebDriverBy::Id("postDelete"))->click(); $this->safeFindElement(WebDriverBy::Name("File_name"))->sendKeys("README.md"); $this->safeFindElement(WebDriverBy::Name("filter"))->click(); sleep(5); $text = $this->safeFindElement(WebDriverBy::cssSelector("tbody"), 3000)->getText(); $this->assertEquals('', $text); }
/** * Modifies a field on either the user account or my preferences page * and checks that the modification was recorded in the database. * * @param string $page either 'user_accounts' or 'user_accounts/my_preferences'. * @param string $userId ID of the user to modify. * @param string $fieldName name of the field (on the HTML page) that should * be modified. * @param string $newValue new field value. * * @return void */ function _verifyUserModification($page, $userId, $fieldName, $newValue) { $this->_accessUser($page, $userId); $field = $this->safeFindElement(WebDriverBy::Name($fieldName)); if ($field->getTagName() == 'input') { $field->clear(); $field->sendKeys($newValue); } else { $selectField = new WebDriverSelect($field); $selectField->selectByVisibleText($newValue); } $this->safeClick(WebDriverBy::Name('fire_away')); $this->_accessUser($page, $userId); $field = $this->safeFindElement(WebDriverBy::Name($fieldName)); if ($field->getTagName() == 'input') { $this->assertEquals($field->getAttribute('value'), $newValue); } else { $selectField = new WebDriverSelect($field); $this->assertEquals($selectField->getFirstSelectedOption()->getText(), $newValue); } }
/** * Create a timepoint with three parameters. * * @param string $canID ID of candidate * @param string $subproject text of Subproject * @param string $visitlabel * @return void. */ private function _createTimepoint($canID, $subproject, $visitlabel) { $this->safeGet($this->url . "/create_timepoint/?candID=" . $canID . "&identifier=" . $canID); $select = $this->safeFindElement(WebDriverBy::Name("subprojectID")); $element = new WebDriverSelect($select); $element->selectByVisibleText($subproject); $this->webDriver->findElement(WebDriverBy::Name("visitLabel"))->sendKeys($visitlabel); $this->webDriver->findElement(WebDriverBy::Name("fire_away"))->click(); }
/** * Select an option in a select list * @param $id string an element id or selector * @param $option string the label of the option */ public function selectOption($id, $option) { $select = new WebDriverSelect($this->driver->findElement(WebDriverBy::id($id))); $select->selectByVisibleText($option); }
/** * Tests that,in the not resolved menu, change the Resolution status of the first row. * Save it and check it. * * @return void */ function testNotResolvedSaveButton() { $this->safeGet($this->url . "/mri_violations/"); $resolutionElement = $this->safeFindElement(WebDriverBy::Name("resolvable[c57b919a921eaa1a43bb5e0c44cd4226]")); $resolution = new WebDriverSelect($resolutionElement); $resolution->selectByVisibleText("Inserted"); $this->safeClick(WebDriverBy::Name("fire_away")); $resolutionElement = $this->safeFindElement(WebDriverBy::Name("resolvable[c57b919a921eaa1a43bb5e0c44cd4226]")); $resolution = new WebDriverSelect($resolutionElement); $value = $resolution->getFirstSelectedOption()->getAttribute('value'); $this->assertEquals("inserted", $value); }
/** * Tests clear button in the form * The form should refreash and the data should be gone. * @return void */ function testdicomArchivFilterClearBtn() { $this->markTestSkipped("This method isn't working properly on travis."); //testing the Patient Name $this->safeGet($this->url . "/dicom_archive/"); $nameElement = $this->safeFindElement(WebDriverBy::Name("PatientName")); $nameElement->sendKeys("TestPatientName"); $this->safeClick(WebDriverBy::Name("reset")); $name = $this->safeFindElement(WebDriverBy::Name("PatientName"))->getAttribute('value'); $this->assertEquals('', $name); //testing the Archive Location $locationElement = $this->safeFindElement(WebDriverBy::Name("Location")); $locationElement->sendKeys("TestLocation"); $this->safeClick(WebDriverBy::Name("reset")); $location = $this->safeFindElement(WebDriverBy::Name("Location"))->getAttribute('value'); $this->assertEquals('', $location); //testing the Patient ID $idElement = $this->safeFindElement(WebDriverBy::Name("PatientID")); $idElement->sendKeys("TestID"); $this->safeClick(WebDriverBy::Name("reset")); $idText = $this->safeFindElement(WebDriverBy::Name("PatientID"))->getAttribute('value'); $this->assertEquals('', $idText); //testing the Gender $genderElement = $this->safeFindElement(WebDriverBy::Name("Gender")); $gender = new WebDriverSelect($genderElement); $gender->selectByVisibleText("Male"); $this->safeClick(WebDriverBy::Name("reset")); $genderElement = $this->safeFindElement(WebDriverBy::Name("Gender")); $gender = new WebDriverSelect($genderElement); $value = $gender->getFirstSelectedOption()->getAttribute('value'); $this->assertEquals("", $value); }
/** * Tests that, input some data and click click clear button, check the results. * The form should refreash and the data should be gone. * @return void */ function testReliabilityClearFormButton() { //testing search by PSCID $this->safeGet($this->url . "/reliability/"); $this->webDriver->findElement(WebDriverBy::Name("PSCID"))->sendKeys("8888"); $this->webDriver->findElement(WebDriverBy::Name("reset"))->click(); $bodyText = $this->webDriver->findElement(WebDriverBy::Name("PSCID"))->getText(); $this->assertEquals("", $bodyText); //testing search by DCCID $this->safeGet($this->url . "/reliability/"); $this->webDriver->findElement(WebDriverBy::Name("DCCID"))->sendKeys("8888"); $this->webDriver->findElement(WebDriverBy::Name("reset"))->click(); $bodyText = $this->webDriver->findElement(WebDriverBy::Name("PSCID"))->getText(); $this->assertEquals("", $bodyText); //testing search by Gender $this->safeGet($this->url . "/reliability/"); $genderElement = $this->safeFindElement(WebDriverBy::Name("Gender")); $gender = new WebDriverSelect($genderElement); $gender->selectByVisibleText("Male"); $this->webDriver->findElement(WebDriverBy::Name("reset"))->click(); $genderElement = $this->safeFindElement(WebDriverBy::Name("Gender")); $gender = new WebDriverSelect($genderElement); $value = $gender->getFirstSelectedOption()->getAttribute('value'); $this->assertEquals("", $value); }