Esempio n. 1
0
 public function waitForTitles($timeout, $titles)
 {
     // what are we doing?
     $log = usingLog()->startAction("check that the the right page has loaded");
     // check the title
     usingTimer()->waitFor(function () use($titles) {
         expectsBrowser()->hasTitles($titles);
     }, $timeout);
     // all done
     $log->endAction();
 }
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    // get the checkpoint, to store data in
    $checkpoint = getCheckpoint();
    // load our test page
    usingBrowser()->gotoPage("file://" . __DIR__ . '/../../testpages/index.html');
    // resize the window
    usingBrowser()->resizeCurrentWindow($checkpoint->expectedDimensions['width'], $checkpoint->expectedDimensions['height']);
    // remember the new size for later
    $checkpoint->actualDimensions = fromBrowser()->getCurrentWindowSize();
    // did the browser change size?
    expectsBrowser()->currentWindowSizeIs($checkpoint->expectedDimensions['width'], $checkpoint->expectedDimensions['height']);
});
// ========================================================================
//
// POST-TEST INSPECTION
//
// ------------------------------------------------------------------------
$story->addPostTestInspection(function () {
    // get the checkpoint
    $checkpoint = getCheckpoint();
    // do we have the dimensions at all?
    assertsObject($checkpoint)->hasAttribute('expectedDimensions');
    assertsObject($checkpoint)->hasAttribute('actualDimensions');
    // do they match?
    assertsArray($checkpoint->actualDimensions)->equals($checkpoint->expectedDimensions);
});
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST PREDICTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST INSPECTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    // load our test page
    usingBrowser()->gotoPage("file://" . __DIR__ . '/../../testpages/index.html');
    // make sure only one heading with this ID exists
    expectsBrowser()->has()->oneHeadingWithId('self_test_website');
});
// ========================================================================
//
// POST-TEST INSPECTION
//
// ------------------------------------------------------------------------
$story->addPostTestInspection(function () {
    // nothing to do
});