public function testIsBrowserstackAccessable() { $response = self::$browserstackApi->isBrowserstackAccessable(); $result = false; if (is_array($response) && (isset($response['success']) || isset($response['errors']))) { $result = true; } $this->assertTrue($result); }
<?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);
<?php require __DIR__ . '/../vendor/autoload.php'; /* * This a simple example how to get a list of browsers currently supported by Browserstack * The given credentials are actually working for that method. * */ use Alexschwarz89\Browserstack\Screenshots\Api; $api = new Api('', ''); $browserList = $api->getBrowsers(); var_dump($browserList);
<?php 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;