本文整理汇总了PHP中AcceptanceTester::grabTextFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP AcceptanceTester::grabTextFrom方法的具体用法?PHP AcceptanceTester::grabTextFrom怎么用?PHP AcceptanceTester::grabTextFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AcceptanceTester
的用法示例。
在下文中一共展示了AcceptanceTester::grabTextFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: EtsyUserCest
private function EtsyUserCest(\AcceptanceTester $I)
{
$result = $this->db->query("SELECT * FROM `etsy_store_list`");
while ($row = $result->fetch_array()) {
$shop = $row['store_slug'];
$I->amOnPage("/shop/{$shop}/reviews?page=1");
try {
$I->waitForElement('.pages>li:last-child', 100);
$last_pg = $I->grabTextFrom('.pages>li:last-child');
for ($pg = 1; $pg <= $last_pg; $pg++) {
$I->amOnPage("/shop/{$shop}/reviews?page=" . $pg);
$I->waitForElement('.reviewer-info', 100);
$break_condition = $I->grabTextFrom('.reviewer-info>span') == 'Reviewed by Anonymous';
if ($break_condition) {
break;
}
$users = $I->grabMultiple('.reviewer-info>a', 'href');
foreach ($users as $user) {
$this->db->real_query("INSERT INTO `etsy_user_list` (`id`, `user_slug`, `from_where`, `sent_at`, `created_at`) VALUES (NULL, '{$user}', '{$shop}', NULL, CURRENT_TIMESTAMP);");
}
}
$this->db->real_query("UPDATE `etsy_store_list` SET `sent_at`= CURRENT_TIMESTAMP WHERE `store_slug` = '{$shop}'");
} catch (\Exception $e) {
}
}
}
示例2: viewProductFromTagPage
public function viewProductFromTagPage(AcceptanceTester $I)
{
$I->wantTo('view a product from tag page');
$I->amOnPage('/t');
$tagName = $I->grabTextFrom("//div[contains(@class,'tag-name')][1]");
$I->click("//div[contains(@class,'tag-container')][1]//a");
$I->see($tagName);
$productName = $I->grabTextFrom("//div[contains(@class,'product-name')][1]");
$I->click("//div[contains(@class,'product-container')][1]//a");
$I->see($productName);
}
示例3: AmazonScrapeCest
private function AmazonScrapeCest(\AcceptanceTester $I)
{
$result = $this->db->query("SELECT * FROM `canopy_item_list`");
//$result = $this->db->query("SELECT * FROM `canopy_item_list` GROUP BY `from_where`");
//$urls = array('http://www.amazon.com/dp/B00HDGJY8S/?tag=','http://www.amazon.com/dp/B00R4O97ZE/?tag=','http://www.amazon.com/dp/B004LRPVM0/?tag=','http://www.amazon.com/dp/B00MKAJP0E/?tag=','http://www.amazon.com/dp/B00KCG10T2/?tag=','http://www.amazon.com/dp/B00JD2LKD2/?tag=','http://www.amazon.com/dp/1477800670/?tag=','http://www.amazon.com/dp/B001797M6S/?tag=','http://www.amazon.com/dp/0316378216/?tag=','http://www.amazon.com/dp/1616892323/?tag=','http://www.amazon.com/dp/B00LW3RCW8?tag=');
while ($row = $result->fetch_assoc()) {
$temp = explode('/', $row['item_slug']);
$id = $temp[4];
$item_info['title'] = '';
$item_info['price'] = '';
$item_info['image_data'] = '';
$I->amOnPage("dp/{$id}");
try {
$I->waitForElement('#productTitle', 10);
$item_info['title'] = $this->db->real_escape_string($I->grabTextFrom('#productTitle'));
} catch (\Exception $e) {
}
try {
$item_info['price'] = $I->grabTextFrom('#priceblock_ourprice');
} catch (\Exception $e) {
try {
$item_info['price'] = $I->grabTextFrom('.header-price');
} catch (\Exception $e) {
try {
$item_info['price'] = $I->grabTextFrom('#buybox .a-color-price');
} catch (\Exception $e) {
try {
$item_info['price'] = $I->grabTextFrom('#unqualifiedBuyBox .a-color-price');
} catch (\Exception $e) {
}
}
}
}
try {
$item_info['image_data'] = $I->grabAttributeFrom('#imgTagWrapperId img', 'data-a-dynamic-image');
} catch (\Exception $e) {
try {
$item_info['image_data'] = $I->grabAttributeFrom('#mainImageContainer img', 'data-a-dynamic-image');
} catch (\Exception $e) {
try {
$item_info['image_data'] = $I->grabAttributeFrom('#img-canvas img', 'data-a-dynamic-image');
} catch (\Exception $e) {
}
}
}
$sql = "UPDATE `canopy_item_list` SET `title`='{$item_info['title']}',`price`='{$item_info['price']}',`image_data`='{$item_info['image_data']}' WHERE `item_slug`='{$row['item_slug']}'";
//codecept_debug($sql);
$this->db->real_query($sql);
$rand_sec = rand(3, 6);
$I->wait($rand_sec);
// remove for faster scrape
}
}
示例4: unlikeComponent
private function unlikeComponent(\AcceptanceTester $I)
{
codecept_debug('unlikeComponent');
$I->wait($this->fill_placeholder_wait);
$pre_like_count = $I->grabTextFrom('.likes-count');
$I->click('.ion-ios-heart');
$I->waitForElement('.ion-ios-heart-outline', 10);
$post_like_count = $I->grabTextFrom('.likes-count');
$I->assertNotEquals($pre_like_count, $post_like_count);
$I->wait($this->send_to_server_wait);
$I->reloadPage();
$I->wait($this->fill_placeholder_wait);
$reload_like_count = $I->grabTextFrom('.likes-count');
$I->assertEquals($reload_like_count, $post_like_count);
}
示例5: strtotime
public function authentication_最終ログイン日時確認(\AcceptanceTester $I)
{
$I->wantTo('EA0201-UC01-T01 最終ログイン日時確認');
$I->click(['css' => '.navbar-menu .dropdown-toggle']);
$loginText = $I->grabTextFrom(['css' => '.navbar-menu .dropdown-menu']);
$lastLogin = preg_replace('/.*(\\d{4}\\/\\d{2}\\/\\d{2} \\d{2}:\\d{2}).*/s', '$1', $loginText);
// 表示されるログイン日時では秒数がわからないため、タイミングによっては1分ちょっと変わる
$I->assertTrue(strtotime('now') - strtotime($lastLogin) < 70, '最終ログイン日時が正しい');
}
示例6: testFindRafflerWinner
/**
* @param AcceptanceTester $I
*/
public function testFindRafflerWinner(AcceptanceTester $I)
{
$I->amOnPage('/');
$visits = mt_rand(50, 1000);
$I->seeElement('h1');
$i = 0;
while ($visits > $i++) {
$I->reloadPage();
$I->seeElement('h1');
}
$winner = $I->grabTextFrom('h1');
$file = fopen("/vagrant/winner.txt", "w");
fwrite($file, PHP_EOL . "The winner is: " . $winner . PHP_EOL);
fclose($file);
}
示例7: _grabLinksFromOnePage
public function _grabLinksFromOnePage(AcceptanceTester $I)
{
$ok = true;
$i = 1;
while ($ok) {
try {
$selector = "#mw-pages > div.category-gallery > div > div.category-gallery-room1 > div:nth-child({$i}) > a";
$text = $I->grabTextFrom($selector);
$this->dragons[] = $text;
$i++;
} catch (\Exception $e) {
$ok = false;
}
}
}
示例8: likes
public function likes(\AcceptanceTester $I)
{
$answer = App\Models\Answer::get()->random();
$user = App\Models\User::get()->random();
\Auth::login($user);
$likes = $answer->likes->count();
$I->wantTo('like answer');
$I->amOnRoute('q', ['id' => $answer->question->id]);
$I->see($answer->question->title);
$c = $likes ? (int) $I->grabTextFrom('li#answer_' . $answer->id . ' a.btn_like .like_count') : 0;
$I->assertEquals($likes, $c);
$I->click('li#answer_' . $answer->id . ' a.btn_like');
$I->amOnRoute('q', ['id' => $answer->question->id]);
$answer = App\Models\Answer::find($answer->id);
$I->assertEquals($likes + 1, $answer->likes->count());
}
示例9: grabDragonInfo
public function grabDragonInfo(AcceptanceTester $I)
{
$this->dragons = json_decode(file_get_contents('dragons.json'));
foreach ($this->dragons as $index => $dragonName) {
if (in_array($dragonName, array_keys($this->dragonInfo))) {
continue;
}
$I->wantTo("Read data of dragon {$dragonName}");
$I->amOnPage("/wiki/{$dragonName}");
$I->waitForElementVisible("#WikiaPageHeader > div > div.header-column.header-title");
try {
$I->see("Article {$dragonName} was not found");
} catch (\Exception $e) {
unset($this->dragons[$index]);
continue;
}
$isClassicDragon = true;
try {
$I->seeElement("#mw-content-text > table.infobox.Template > tbody");
} catch (\Exception $e) {
$isClassicDragon = false;
}
if ($isClassicDragon) {
$dragon = new Dragon();
$dragon->name = $dragonName;
$dragon->fishPerHour = $I->grabTextFrom("//*[@id=\"mw-content-text\"]/table[1]/tbody/tr[td//text()[contains(., 'Fish.png')]]/td[2]");
$dragon->woodPerHour = $I->grabTextFrom("//*[@id=\"mw-content-text\"]/table[1]/tbody/tr[td//text()[contains(., 'Wood.png')]]/td[2]");
try {
$dragon->collectionTime = $I->grabTextFrom("//*[@id=\"mw-content-text\"]/table[1]/tbody/tr[td//text()[contains(., 'Time.png')]]/td[2]");
} catch (\Exception $e) {
$dragon->collectionTime = "TODO: add";
}
$dragon->iron = $I->grabTextFrom("//*[@id=\"mw-content-text\"]/table[1]/tbody/tr[td//text()[contains(., 'Iron-Icon.png')]]/td[2]");
if ($dragon->iron != "Cannot Collect") {
$dragon->ironCollectionTime = $I->grabTextFrom("//*[@id=\"mw-content-text\"]/table[1]/tbody/tr[td//text()[contains(., 'Time.png')]][2]/td[2]");
} else {
$dragon->ironCollectionTime = "Cannot Collect";
}
try {
$dragon->battleRange = $I->grabTextFrom("//*[@id=\"mw-content-text\"]/table[1]/tbody/tr[td//text()[contains(., 'Range_Icon.png')]]/td[2]");
} catch (\Exception $e) {
$dragon->battleRange = "TODO: add";
}
$this->dragonInfo[$dragonName] = $dragon;
} else {
$this->dragonInfo[$dragonName] = "Not classic dragon.";
}
}
}
示例10: unlikePostOnCard
private function unlikePostOnCard(\AcceptanceTester $I)
{
$I->wantTo('unlike post on card');
$I->amOnPage('/');
// card
$I->waitForElement('a.unlike-post[data-id="560"]', 10);
$pre_like_count = $I->grabTextFrom('.like-post-count[data-id="560"]');
$I->click('a.unlike-post[data-id="560"]');
$I->waitForElementVisible('a.like-post[data-id="560"]', 10);
$I->waitForElementNotVisible('a.unlike-post[data-id="560"]', 10);
$post_like_count = $I->grabTextFrom('.like-post-count[data-id="560"]');
$I->assertEquals($pre_like_count, $post_like_count + 1);
$I->amOnPage('/post/560');
$I->waitForElement('.like-post-count[data-id="560"]', 10);
$post_like_count = $I->grabTextFrom('.like-post-count[data-id="560"]');
$I->assertEquals($pre_like_count, $post_like_count + 1);
}
示例11: configureInstalledExtensions
/**
* Test that the 'developer' user can configure installed extensions.
*
* @param \AcceptanceTester $I
*/
public function configureInstalledExtensions(\AcceptanceTester $I, \Codeception\Scenario $scenario)
{
$I->wantTo("See that the 'developer' user can configure installed extensions.");
// Set up the browser
$I->setCookie($this->tokenNames['authtoken'], $this->cookies[$this->tokenNames['authtoken']]);
$I->setCookie($this->tokenNames['session'], $this->cookies[$this->tokenNames['session']]);
$I->amOnPage('/bolt/files/config/extensions');
$I->see('testerevents.bolt.yml', Locator::href('/bolt/file/edit/config/extensions/testerevents.bolt.yml'));
$I->click('testerevents.bolt.yml', Locator::href('/bolt/file/edit/config/extensions/testerevents.bolt.yml'));
$I->see('# Sit back and breathe', 'textarea');
$I->see('its_nice_to_know_you_work_alone: true', 'textarea');
// Edit the field
$twig = $I->grabTextFrom('#form_contents', 'textarea');
$twig .= PHP_EOL . "# Let's make this perfectly clear";
$twig .= PHP_EOL . 'theres_no_secrets_this_year: true' . PHP_EOL;
$I->fillField('#form_contents', $twig);
$token = $I->grabValueFrom('#form__token');
$I->sendAjaxPostRequest('/bolt/file/edit/config/extensions/testerevents.bolt.yml', ['form[_token]' => $token, 'form[contents]' => $twig]);
$I->amOnPage('/bolt/file/edit/config/extensions/testerevents.bolt.yml');
$I->see("# Let's make this perfectly clear", 'textarea');
$I->see('theres_no_secrets_this_year: true', 'textarea');
}
示例12: unlikePostOnCard
private function unlikePostOnCard(\AcceptanceTester $I)
{
codecept_debug('unlikePostOnCard');
$I->amOnPage('/' . $this->user_slug . '/postgroups/' . $this->postgroup_slug);
// card
$I->waitForElement('.btn.unlike-post[data-id="' . $this->post_id . '"]', 10);
$pre_like_count = $I->grabTextFrom('.like-post-count[data-id="' . $this->post_id . '"]');
$I->click('.btn.unlike-post[data-id="' . $this->post_id . '"]');
$I->waitForElementVisible('.btn.like-post[data-id="' . $this->post_id . '"]', 10);
$I->waitForElementNotVisible('.btn.unlike-post[data-id="' . $this->post_id . '"]', 10);
$post_like_count = $I->grabTextFrom('.like-post-count[data-id="' . $this->post_id . '"]');
$I->assertEquals($pre_like_count, $post_like_count + 1);
$I->amOnPage('/post/' . $this->post_id);
$I->waitForElement('.like-post-count[data-id="' . $this->post_id . '"]', 10);
$post_like_count = $I->grabTextFrom('.like-post-count[data-id="' . $this->post_id . '"]');
$I->assertEquals($pre_like_count, $post_like_count + 1);
}
示例13: AcceptanceTester
*/
$I = new AcceptanceTester($scenario);
$I->wantTo('login to wp-admin');
$I->amOnPage(site_url() . '/wp-login.php');
$I->fillField('Username', 'admin');
$I->fillField('Password', 'admin');
$I->click('Log In');
$I->see('Dashboard');
$I->wantTo('Navigate to landing pages list');
$I->click('Landing Pages');
$I->amOnPage(admin_url('edit.php?post_type=landing-page'));
$I->see('Landing Pages');
$I->wantTo('Open example landing page');
$I->click(['link' => 'A/B Testing Landing Page Example']);
$I->wantTo('check if impressions are correct for variation a');
$imp = $I->grabTextFrom('#lp-variation-A .bab-stat-span-impressions');
$I->assertContains('30', $imp);
$I->wantTo('check check impressions for variation b');
$imp = $I->grabTextFrom('#lp-variation-B .bab-stat-span-impressions');
$I->assertContains('35', $imp, '');
$I->wantTo('check conversions for variation a');
$con = $I->grabTextFrom('#lp-variation-A .bab-stat-span-conversions');
$I->assertContains('10', $con, '');
$I->wantTo('check conversions for variation b');
$con = $I->grabTextFrom('#lp-variation-B .bab-stat-span-conversions');
$I->assertContains('15', $con);
$I->wantTo('check the conversion rate of variation a');
$per = $I->grabTextFrom('#lp-variation-A .bab-stat-span-conversion_rate');
$I->assertContains('33', $per);
$I->wantTo('check the conversion rate of variation b');
$per = $I->grabTextFrom('#lp-variation-B .bab-stat-span-conversion_rate');
示例14: tryToTest
public function tryToTest(AcceptanceTester $I)
{
$this->allTests = loadFromJson(__DIR__ . '/../tests.json');
$this->currentTest = [];
//idčka první odpovědi k otázkám v testu
$I->wantTo('fill test and download results');
$I->amOnPage('/login.php?id=127');
$I->click('input[type="submit"]');
$I->seeInCurrentUrl('test');
$I->see('testu stiskem');
for ($i = 1; $i <= 30; $i++) {
$questionText = $I->grabTextFrom("~{$i}.<\\/b> otázka \\(.*?\\) - +<b>(.*?)<\\/b>~");
$answer1number = $I->grabTextFrom("~<TD VALIGN=\"MIDDLE\"><INPUT TYPE=\"radio\" VALUE=\"(\\d+)\" NAME=\"a{$i}\" \\/><\\/TD><TD>(.*?)<BR /></TD>~i");
$this->currentTest[] = $answer1number;
if (array_key_exists($answer1number, $this->allTests)) {
} else {
/** @var Answer[] $answers */
$answers = [];
$answersCount = $I->getNumberOfElements("input[name=a{$i}]");
for ($j = 0; $j < $answersCount; $j++) {
$number = $answer1number + $j;
$answerText = $I->grabTextFrom("~<TD VALIGN=\"MIDDLE\"><INPUT TYPE=\"radio\" VALUE=\"{$number}\" NAME=\"a{$i}\" \\/><\\/TD><TD>(.*?)<BR /></TD>~i");
$answers[] = new Answer($answerText, null, $number, false);
}
$this->allTests[$answer1number] = new Question($questionText, $answers);
}
}
//naklikání nevyzkoušených odpovědí
foreach ($this->currentTest as $answer1number) {
/** @var Question $question */
$question = $this->allTests[$answer1number];
$I->wantTo('select correct answer of ' . json_encode($question));
if ($question->hasCorrectAnswer()) {
$id = $question->correctAnswer->id;
$I->click("input[value=\"{$id}\"]");
continue;
}
foreach ($question->answers as $answer) {
if (!$answer->tried) {
//první nevyzkoušená otázka
$id = $answer->id;
$I->click("input[value=\"{$id}\"]");
$question->selected = $answer;
$answer->tried = true;
break;
}
}
}
//submit formuláře
$I->click('input[type=button]');
//přečtení správnosti
$i = 0;
foreach ($this->currentTest as $answer1number) {
/** @var Question $question */
$question = $this->allTests[$answer1number];
$i++;
//číslo otázky
if (!$question->hasCorrectAnswer()) {
$image = $I->grabTextFrom("~<img alt=\"status\" src=\"(.*?)\"(.*?)</td><td><b>{$i}\\.~i");
if ($image == 'img/icon_good.jpg') {
$question->selected->correct = true;
$question->correctAnswer = $question->selected;
}
}
}
foreach ($this->allTests as $questionText => $question) {
$question->selected = null;
}
file_put_contents('tests.json', json_encode($this->allTests, JSON_PRETTY_PRINT));
}
示例15: AcceptanceTester
<?php
// @group: settings
$I = new AcceptanceTester($scenario);
//Activate TEC Calendar
$I->am('administrator');
$I->wantTo("verify that deleted events can't be viewed on front end");
$I->activate_tec();
$I->set_pretty_permalinks();
//Set up test Event and test it exists
$I->createEvent(array('title' => 'Test Event A'));
$event_url = $I->grabTextFrom('#sample-permalink');
$I->amOnPage($event_url);
$I->see('Test Event A');
//Delete Event
$I->click('.quicklinks #wp-admin-bar-edit a');
$I->click('Move to Trash');
$I->amOnPage($event_url);
$I->see('Oops! That page');