示例#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;
 }
<?php

require __DIR__ . '/../vendor/autoload.php';
/*
 * This an example of the more advanced way of building requests
 * 
 */
use Alexschwarz89\Browserstack\Screenshots\Api;
use Alexschwarz89\Browserstack\Screenshots\Request;
const BROWSERSTACK_ACCOUNT = '';
const BROWSERSTACK_PASSWORD = '';
$api = new Api(BROWSERSTACK_ACCOUNT, BROWSERSTACK_PASSWORD);
$request = new Request();
$request->url = 'http://www.example.org';
$request->mac_res = '1920x1080';
$request->win_res = '1920x1080';
$request->quality = 'Original';
$request->wait_time = 10;
$request->orientation = 'landscape';
$request->addBrowser('ios', '8.0', 'Mobile Safari', NULL, 'iPhone 6');
$request->addBrowser('ios', '8.0', 'Mobile Safari', NULL, 'iPhone 6 Plus');
$request->addBrowser('Windows', 'XP', 'ie', '7.0');
// Send the request
$api->sendRequest($request);
// Output
var_dump($request);
 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;
        }