/** * Checking current parameters in Delivery List page * if you want to skip verifying of some parameters type null * @param sring $name Delivery name * @param string $active Active checkbox on - enabled |off - disabled * @param int|string|float $price Delivery price * @param int|string|float $freefrom Delivery free from * @return void */ function CheckInList($name, $active = null, $price = null, $freefrom = null) { $I = $this; $I->wait(3); $I->amOnPage(\DeliveryPage::$URL); $I->waitForText('Список способов доставки'); $rows = $I->grabTagCount($I, "tbody tr"); $I->comment($rows); $present = FALSE; if ($rows > 0) { for ($j = 1; $j <= $rows; ++$j) { $method = $I->grabTextFrom(\DeliveryPage::ListMethodLine($j)); $I->comment($method); if ($method == $name) { $present = TRUE; break; } } } $I->comment("results: \n Method: \n{$method} Present: {$present} in row: {$j}\n"); //Error when method isn't present in delivery list page $present ? $I->assertEquals($method, $name) : $I->fail("Method wasn't created"); if ($active) { $attribute = $I->grabAttributeFrom(\DeliveryPage::ListActiveButtonLine($j), "class"); switch ($active) { case 'on': $I->assertEquals("prod-on_off ", $attribute); break; case 'off': $I->assertEquals("prod-on_off disable_tovar", $attribute); break; } } if ($price) { $Cprice = $I->grabTextFrom(\DeliveryPage::ListPriceLine($j)); $price = number_format($price, 5, ".", ""); $I->assertEquals(preg_replace('/[^0-9.]*/u', '', $Cprice), $price); } if ($freefrom) { $Cfreefrom = $I->grabTextFrom(\DeliveryPage::ListFreeFromLine($j)); $freefrom = number_format($freefrom, 5, ".", ""); $I->assertEquals(preg_replace('/[^0-9.]*/u', '', $Cfreefrom), $freefrom); } }
/** * Verify that unactive method isn't present at frontend * * @group list * @guy DeliveryTester\DeliverySteps */ public function toggleUnActive(DeliveryTester\DeliverySteps $I) { $I->amOnPage(DeliveryPage::$URL); $row = $I->SearchDeliveryMethod($this->name); if ($row) { $ActiveButtonClass = $I->grabAttributeFrom(DeliveryPage::ListActiveButtonLine($row), 'class'); $I->comment($ActiveButtonClass); if ($ActiveButtonClass == 'prod-on_off ') { $I->click(DeliveryPage::ListActiveButtonLine($row)); } $missing = $I->CheckMethodNotPresentInFrontEnd($this->name); if (!$missing) { $I->fail('Unactive Method is present in front end'); } elseif ($missing) { $I->assertEquals(true, true, "Unactive Method is missing in front end"); } } else { $I->fail('There are no method $this->name for testing ToggleUnActive, create it before test'); } }