/** @test */ public function sampleTest() { $page = $this->driver->get('http://slovicka.my'); $this->assertContains('Slovicka', $page->getTitle()); $username = $this->driver->findElement(WebDriverBy::name('_username')); $username->sendKeys('*****@*****.**'); }
/** * Find all WebDriverElements within the current page using the given * mechanism. * * @param WebDriverBy $by * @return array A list of all WebDriverElements, or an empty array if * nothing matches * @see WebDriverBy */ public function findElements(WebDriverBy $by) { $params = array('using' => $by->getMechanism(), 'value' => $by->getValue()); $raw_elements = $this->executor->execute('findElements', $params); $elements = array(); foreach ($raw_elements as $raw_element) { $elements[] = $this->newElement($raw_element['ELEMENT']); } return $elements; }
/** * Поиск продукта по названию и переход на страницу * @param String $link_text * @return Page_Product */ public function click_product_by_link_text($link_text) { $wait = new WebDriverWait($this->web_driver, 30); $wait->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::linkText($link_text))); $this->web_driver->findElement(WebDriverBy::linkText($link_text))->click(); return new Page_Product($this->web_driver); }
public function testGoogle() { $this->driver->get(Util::buildUrl('/')); echo $this->driver->getTitle(); echo $this->driver->findElement(WebDriverBy::id('id1'))->getText(); $this->driver->takeScreenshot(ROOT . '/tests/tmp/sc.png'); }
/** * @test */ public function validaTempoDeMensagemVoceEPassienteEm7Segundos() { $this->driver->manage()->timeouts()->implicitlyWait(2); $this->driver->get($this->url); $mensagem = $this->driver->findElement(WebDriverBy::id("mensagem-magica"))->getText(); $this->assertEquals("Voce e paciente!", $mensagem); }
public function test1() { $aAdVals = array('ad_id' => 1989, 'location' => array('VN', 'US'), 'ad_type' => Phpfox::getService('socialad.helper')->getConst('ad.type.html')); Phpfox::getService('unittest.test.socialad')->insertTestAd($aAdVals); $this->driver->get($this->url); $search = $this->driver->findElement(WebDriverBy::cssSelector('.header_menu_login_left .header_menu_login_input')); $search->click(); $this->driver->getKeyboard()->sendKeys('*****@*****.**'); // need refactoring $search = $this->driver->findElement(WebDriverBy::cssSelector('.header_menu_login_right .header_menu_login_input')); $search->click(); $this->driver->getKeyboard()->sendKeys('123456'); $search = $this->driver->findElement(WebDriverBy::cssSelector('.header_menu_login_button input')); $search->click(); // checking that page title contains word 'GitHub' $by = WebDriverBy::cssSelector('#ynsaAdDisplay_' . $aAdVals['ad_id']); $this->assertElementFound($by); $search = $this->driver->findElement(WebDriverBy::cssSelector('#ynsaAdDisplay_' . $aAdVals['ad_id'])); $this->driver->executeScript('$(".ynsaDisplayAdHideButton").show();'); // $search->click(); // $this->driver->getMouse()->mouseMove($search->getCoordinates()); $search = $this->driver->findElement(WebDriverBy::cssSelector('#ynsaAdDisplay_' . $aAdVals['ad_id'] . ' .ynsaDisplayAdHideButton')); $search->click(); $search = $this->driver->findElement(WebDriverBy::cssSelector('#ynsaAdDisplay_' . $aAdVals['ad_id'] . ' .ynsaDisplayAdBlock')); $this->assertFalse($search->isDisplayed()); // need a function convert xPath to css selector $search = $this->driver->findElement(WebDriverBy::cssSelector('#header_menu_holder ul:nth-child(1) > li:nth-child(3) > a:nth-child(1)')); $search->click(); $search = $this->driver->findElement(WebDriverBy::cssSelector('#header_menu_holder ul:nth-child(1) > li:nth-child(3) > ul > li:nth-child(6) a')); $search->click(); }
public function testGoogle2() { static::$driver->get(Util::buildUrl('/')); echo static::$driver->getTitle(); echo static::$driver->findElement(WebDriverBy::id('id1'))->getText(); static::$driver->takeScreenshot(ROOT . '/tests/tmp/sc1.png'); }
/** * @dataProvider userLocations */ public function testUserLocation($proxy, $expected) { $this->driver = $this->proxied($proxy); $this->driver->get($this->url); $search = $this->driver->findElement(WebDriverBy::id('user-city')); $this->assertContains($expected, $search->getText()); }
public function testEmptyField() { $this->clearData(); $this->submitForm(); $this->assertEquals($this->baseUrl . "/system/company", $this->webDriver->getCurrentURL()); $this->assertEquals(1, count($this->webDriver->findElement(WebDriverBy::className("error-box")))); }
public function testProcessOrder() { $this->driver->get($this->getTestPath('/admin')); $this->driver->findElement(WebDriverBy::id('username'))->sendKeys('admin'); $this->driver->findElement(WebDriverBy::id('login'))->sendKeys('P@ssw0rd'); $this->driver->findElement(WebDriverBy::className('form-button'))->click(); $this->driver->findElement(WebDriverBy::xpath("//span[text()='Sales']"))->click(); $this->driver->findElement(WebDriverBy::xpath("//span[text()='Orders']"))->click(); $this->driver->wait()->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::id('sales_order_grid_filter_real_order_id'))); $this->driver->findElement(WebDriverBy::id('sales_order_grid_filter_real_order_id'))->sendKeys('ICANN-D10000014'); $this->driver->findElement(WebDriverBy::id('sales_order_grid_filter_real_order_id'))->sendKeys(WebDriverKeys::ENTER); sleep(3); $this->driver->findElement(WebDriverBy::xpath("//html/body/div[1]/div[2]/div/div[3]/div/div[2]/div/table/tbody/tr[1]/td[2]"))->click(); $this->driver->findElement(WebDriverBy::xpath("//span[text()='Invoice']"))->click(); $this->driver->findElement(WebDriverBy::xpath("//span[text()='Submit Invoice']"))->click(); $this->driver->findElement(WebDriverBy::xpath("//span[text()='Ship']"))->click(); $this->driver->findElement(WebDriverBy::xpath("//span[text()='Add Tracking Number']"))->click(); $this->driver->findElement(WebDriverBy::id("trackingC1"))->click(); $this->driver->findElement(WebDriverBy::xpath("//select[@id='trackingC1']/option[@value='fedex']"))->click(); $this->driver->findElement(WebDriverBy::id("trackingT1"))->sendKeys('FEDEX'); $this->driver->findElement(WebDriverBy::id("trackingN1"))->sendKeys('Tracking0001'); $this->driver->findElement(WebDriverBy::id("send_email"))->click(); $this->driver->findElement(WebDriverBy::xpath("//span[text()='Submit Shipment']"))->click(); sleep(5); }
/** * @test */ public function 質問ページから質問投稿する() { // $basic_user = '******'; // $basic_pass = '******'; // $gooid_user = '******'; // $gooid_pass = '******'; // $domain = '*****.goo.ne.jp'; require __DIR__ . '/../config.php'; $basic_user = urlencode($basic_user); $basic_pass = urlencode($basic_pass); $title = 'タイトル' . time(); $description = '本文' . time(); $driver = Util::createDriver(); Util::loginToGoo($driver, $gooid_user, $gooid_pass); $driver->get("http://{$basic_user}:{$basic_pass}@{$domain}/question"); $driver->findElement(\WebDriverBy::id('title_area'))->sendKeys($title); $driver->findElement(\WebDriverBy::id('text_area'))->sendKeys($description); $driver->findElement(\WebDriverBy::cssSelector('#question_confirm_btn > a > span.q-text'))->click(); Util::skipPageLenvingAlert($driver); $driver->wait(5)->until(\WebDriverExpectedCondition::visibilityOfElementLocated(\WebDriverBy::cssSelector('#match_categories > input'))); $driver->findElement(\WebDriverBy::cssSelector('#question_complete_button > a'))->click(); $driver->findElement(\WebDriverBy::cssSelector('li.tooSeeBtn > a'))->click(); $actual_title = $driver->getTitle(); $url = $driver->getCurrentUrl(); preg_match('/\\/qa\\/(\\d+)\\.html/', $url, $matches); $qid = $matches[1]; $trimed_title = preg_replace('/ - .+/', '', $actual_title); echo $actual_title . "\n"; echo $url . "\n"; echo $qid . "\n"; $driver->quit(); $this->assertEquals($title, $trimed_title); }
public function testTestPageWelcome() { $this->driver->get($this->getTestPath('index.html')); self::assertEquals( 'Welcome to the facebook/php-webdriver testing page.', $this->driver->findElement(WebDriverBy::id('welcome'))->getText() ); }
public function testBlankFields() { //click with empty data $this->submitForm(); $this->assertEquals($this->baseUrl . "/system/permissions/create", $this->webDriver->getCurrentURL()); $this->assertEquals(1, count($this->webDriver->findElement(WebDriverBy::className("error-box")))); }
public function testUselessFileDetectorSendKeys() { $this->driver->get($this->getTestPath('upload.html')); $file_input = $this->driver->findElement(WebDriverBy::id('upload')); $file_input->sendKeys($this->getFilePath()); self::assertEquals($this->getFilePath(), $file_input->getAttribute('value')); }
/** * @param RemoteWebElement $fieldContext * @param array $testValues An array of arrays that contains the values to validate. * * First value is the input value * * second value is the value that is expected after the validation * * optional third value is the "internal" value like required for date fields (value is internally * represented by a timestamp). If this value is not defined the second value will be used. * Example for field with alpha validation: [['foo', 'foo'], ['bar1'], ['bar']] * Example for field with date validation: [['29-01-2016', '29-01-2016', '1454025600']] */ public function fillSeeDeleteInputField(RemoteWebElement $fieldContext, array $testValues) { $I = $this->tester; $I->wantTo('Fill field, check the fieldvalue after evaluation and delete the value.'); $inputField = $fieldContext->findElement(\WebDriverBy::xpath('.//*/input[@data-formengine-input-name]')); $internalInputField = $fieldContext->findElement(\WebDriverBy::xpath('.//*/input[@name="' . $inputField->getAttribute('data-formengine-input-name') . '"]')); foreach ($testValues as $comment => $testValue) { if (!empty($comment)) { $I->comment($comment); } $I->comment('Fill the field and switch focus to trigger validation.'); $I->fillField($inputField, $testValue[0]); // change the focus to trigger validation $fieldContext->sendKeys("\n"); $I->comment('Test value of "visible" field'); $I->canSeeInField($inputField, $testValue[1]); $I->comment('Test value of the internal field'); $I->canSeeInField($internalInputField, isset($testValue[2]) ? $testValue[2] : $testValue[1]); } $inputField->findElement(\WebDriverBy::xpath('parent::*/button[@class="close"]'))->click(); // change the context from the field $fieldContext->sendKeys("\n"); $I->canSeeInField($inputField, ''); $I->canSeeInField($internalInputField, ''); }
/** * @param Admin $I */ public function tryToTest(Admin $I) { // Select page module $I->wantToTest('Add a page with page module'); $I->click('Page'); // New page from root page $typo3NavigationContainer = '#typo3-navigationContainer'; $I->waitForElement($typo3NavigationContainer); $rootNode = 'a.x-tree-node-anchor > span'; $rootNodeIcon = '#extdd-1 > span.t3js-icon.icon.icon-size-small.icon-state-default.icon-apps-pagetree-root'; $contextMenuNew = '#typo3-pagetree-contextmenu > ul > li.x-menu-list-item:nth-of-type(2) > a > span.x-menu-item-text'; $I->waitForElement($rootNode); $I->click($rootNodeIcon); $I->waitForElement($contextMenuNew); $I->click($contextMenuNew); // Switch to content frame $I->switchToIFrame('content'); // New page select position wizard $I->click('i[title="Insert the new page here"]'); // FormEngine new page record $saveButton = 'body > div > div.module-docheader.t3js-module-docheader > div.module-docheader-bar.module-docheader-bar-buttons.t3js-module-docheader-bar.t3js-module-docheader-bar-buttons > div.module-docheader-bar-column-left > div > div > button:nth-child(1)'; $I->waitForElement($saveButton); // Check empty $I->amGoingTo('check empty error'); $I->click($saveButton); $I->wait(2); $editControllerDiv = '#EditDocumentController > div'; $generalTab = $editControllerDiv . ' > div:nth-child(1) > ul > li'; $classString = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use($generalTab) { return $webdriver->findElement(\WebDriverBy::cssSelector($generalTab))->getAttribute('class'); }); $I->assertContains('has-validation-error', $classString); // Add page $pageTitle = $editControllerDiv . ' > div:nth-child(1) > div > div.tab-pane:nth-child(1) > fieldset:nth-child(2) > div > div:nth-child(1) > div > div.form-control-wrap > div > input'; $I->fillField($pageTitle, 'Testpage'); $I->click($saveButton); $I->waitForElement($pageTitle); $I->assertEquals('Testpage', $I->grabValueFrom($pageTitle), 'Value in input field.'); $I->switchToIFrame(); // Check tree $I->waitForElement($typo3NavigationContainer); $pageInTree = '#typo3-pagetree-tree > div > div > ul > div > li > ul > li > div > a > span'; $I->assertEquals('Testpage', $I->grabTextFrom($pageInTree), 'Value in tree.'); // And delete page from tree $pageInTreeIcon = '#typo3-pagetree-tree > div > div > ul > div > li > ul > li > div > span.t3js-icon.icon.icon-size-small.icon-state-default.icon-apps-pagetree-page-default'; $pageActions = '#typo3-pagetree-contextmenu > ul > li:nth-child(8) > a > span.x-menu-item-text'; $delete = '#typo3-pagetree-contextmenu-sub1 > ul > li:nth-child(6) > a > span.x-menu-item-text'; $I->click($pageInTreeIcon); $I->waitForElement('#typo3-pagetree-contextmenu'); $I->waitForElement($pageActions); $I->moveMouseOver($pageActions); $I->waitForElement('#typo3-pagetree-contextmenu-sub1'); $I->click($delete); $yesButtonPopup = '#main > div.x-window.x-window-plain.x-window-dlg > div.x-window-bwrap > div.x-window-bl > div > div > div > div.x-panel-fbar.x-small-editor.x-toolbar-layout-ct > table > tbody > tr > td.x-toolbar-left > table > tbody > tr > td:nth-child(2) > table > tbody > tr:nth-child(2) > td.x-btn-mc > em > button'; $I->waitForElement($yesButtonPopup); $I->click($yesButtonPopup); $I->wait(2); $I->cantSee('Testpage'); }
/** * Tests that Instrument list loads with permission * * @return void */ function testInstrumentListDoespageLoadWithPermission() { $this->setupPermissions(array("access_all_profiles")); $this->webDriver->get($this->url . "/instrument_list/"); $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); $this->assertContains("instrument_list", $bodyText); $this->resetPermissions(); }
/** * Tests that, when loading the instrument_manager module without permission, some * text appears in the body. * * @return void */ function testInstrumentManagerDoespageLoadWithoutpermission() { $this->setupPermissions(array()); $this->safeGet($this->url . "/instrument_manager/"); $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); $this->assertContains("You do not have access to this page.", $bodyText); $this->resetPermissions(); }
/** @When /^I search for "([^"]*)"$/ */ public function iSearchFor($searchText) { $element = $this->webDriver->findElement(WebDriverBy::name("q")); if ($element) { $element->sendKeys($searchText); $element->submit(); } }
public function testShouldNotLogCommandsInNormalMode() { $this->setDebugMode(false); // Make debug mode disabled $this->driver->findElement(\WebDriverBy::className('foo')); $this->driver->getTitle(); $this->expectOutputString(''); }
/** * Tests that help editor loads with the permission * * @return void */ function testDataTeamHelperPermission() { $this->setupPermissions(array("data_team_helper")); $this->safeGet($this->url . "/data_team_helper/"); $bodyText = $this->safeFindElement(WebDriverBy::cssSelector("body"))->getText(); $this->assertNotContains("You do not have access to this page.", $bodyText); $this->resetPermissions(); }
public function getAllDeals() { $dealsElements = $this->element->findElements(\WebDriverBy::cssSelector(self::DEALS_SELECTOR)); $deals = []; foreach ($dealsElements as $element) { $deals[] = new Deal($element); } return $deals; }
/** * Tests that the final Radiological Review loads if the user has the correct * permissions (edit_final_radiological_review or view_final_radiological_review) * It should only be able to see the menu item. * @return void */ function testFinalRadiologicalReviewLoadsWithPermission() { $this->setupPermissions(array("view_final_radiological_review")); $this->safeGet($this->url . "/final_radiological_review/"); // Test that the Imaging menu appears in the first row $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); $this->assertNotContains("You do not have access to this page.", $bodyText); $this->resetPermissions(); }
public function testLimitReachedDismisses() { $this->set_api_key('LIMIT123'); $this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png'); self::$driver->findElement(WebDriverBy::cssSelector('.tiny-notice button, .tiny-notice a.tiny-dismiss'))->click(); self::$driver->wait(2)->until(WebDriverExpectedCondition::invisibilityOfElementWithText(WebDriverBy::cssSelector('.tiny-dismiss'), 'Dismiss')); self::$driver->get(wordpress('/wp-admin/options-media.php')); $this->assertEquals(0, count(self::$driver->findElements(WebDriverBy::cssSelector('div.error p')))); }
public static function loginToGoo($driver, $goo_id, $password) { require ROOT . '/tests/config.php'; $driver->get('https://login.mail.goo.ne.jp/id/authn/LoginStart'); $driver->findElement(\WebDriverBy::id('uname'))->sendKeys($goo_id); $element = $driver->findElement(\WebDriverBy::id('pass')); $element = $element->sendKeys($password); $element->submit(); }
static function getHotels() { $hotelsElements = self::getElement("hotelList")->findElements(\WebDriverBy::cssSelector("li.hotel")); $hotels = []; foreach ($hotelsElements as $element) { $hotels[] = new Hotel($element); } return $hotels; }
public function testBulkCompressShouldCompressUncompressedSizes() { $this->enable_compression_sizes(array('thumbnail')); $this->set_api_key('PNG123'); $this->upload_image(dirname(__FILE__) . '/../fixtures/example-large.png'); $this->enable_compression_sizes(array('thumbnail', 'medium')); media_bulk_action(self::$driver, 'tinypng_bulk_compress'); $this->assertContains('Compressed 2 out of 2 sizes', self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images'))->getText()); }
/** * @return int */ public function noOfTrainResultsOnPage() { $i = $this->actor; $elements = array(); $i->executeInSelenium(function (\RemoteWebDriver $webDriver) use(&$elements) { $elements = $webDriver->findElements(\WebDriverBy::cssSelector('div[id="results-train"] div[class="result"]')); }); return count($elements); }
/** * @test */ public function gooIDログインする() { require ROOT . '/tests/config.php'; $driver = Util::createSmartPhoneUaDriver(); $driver->get('https://login.mail.goo.ne.jp/id/authn/LoginStart'); $driver->findElement(\WebDriverBy::id('uname'))->sendKeys($gooid_user); $element = $driver->findElement(\WebDriverBy::id('pass')); $element = $element->sendKeys($gooid_pass); $element->submit(); }
public function testGoogle() { $web_driver = Util::createDriver(); $web_driver->get("http://www.google.com"); $element = $web_driver->findElement(WebDriverBy::name("q")); if ($element) { $element->sendKeys("Browserstack"); $element->submit(); } $web_driver->quit(); }