Example #1
0
 public function testSendRequest()
 {
     $request = Request::buildRequest('http://www.example.com', 'Windows', '8.1', 'ie', '11.0');
     $this->assertInstanceOf('Alexschwarz89\\Browserstack\\Screenshots\\Request', $request);
     $response = self::$browserstackApi->sendRequest($request);
     $this->assertInstanceOf('Alexschwarz89\\Browserstack\\Screenshots\\Response\\ScreenshotsResponse', $response);
     return false;
 }
 public function testBuildRequest()
 {
     $request = Request::buildRequest('http://www.example.org', 'Windows', '8.1', 'ie', '11.0');
     $this->assertInstanceOf('\\Alexschwarz89\\Browserstack\\Screenshots\\Request', $request);
 }
require __DIR__ . '/../vendor/autoload.php';
/*
 * This a simple example for a complete process-implementation
 *  generating a screenshot
 *  querying the information
 *  receive a list of generated screenshots
 *
 */
use Alexschwarz89\Browserstack\Screenshots\Api;
use Alexschwarz89\Browserstack\Screenshots\Request;
const BROWSERSTACK_ACCOUNT = '';
const BROWSERSTACK_PASSWORD = '';
$api = new Api(BROWSERSTACK_ACCOUNT, BROWSERSTACK_PASSWORD);
// Short-hand Notation
$request = Request::buildRequest('http://www.example.org', 'Windows', '8.1', 'ie', '11.0');
// Send the request
$response = $api->sendRequest($request);
// Query information about the newly created request
if ($response->isSuccessful) {
    // Wait until the request is finished
    do {
        // Query Job Status
        $status = $api->getJobStatus($response->jobId);
        if ($status->isFinished()) {
            // When it's finished, print out the image URLs
            foreach ($status->finishedScreenshots as $screenshot) {
                print $screenshot->image_url . "\n";
            }
            break;
        }