Skip to content

Instantly share code, notes, and snippets.

@zulfajuniadi
Created January 19, 2017 09:57
Show Gist options
  • Save zulfajuniadi/f332f5404fc619e353e1ba3ccba5ae2e to your computer and use it in GitHub Desktop.
Save zulfajuniadi/f332f5404fc619e353e1ba3ccba5ae2e to your computer and use it in GitHub Desktop.
Facebook Messenger Automation using Laravel Dusk
<?php
namespace Tests\Browser;
use Tests\DuskTestCase;
class ExampleAnnoyAjayTest extends DuskTestCase
{
/**
* A basic browser test example.
*
* @return void
*/
public function testBasicExample()
{
$this->browse(function ($browser) {
$client = new \GuzzleHttp\Client();
$response = $client->get('http://catfacts-api.appspot.com/api/facts');
$contents = json_decode($response->getBody()->getContents());
$fact = $contents->facts[0];
$browser
->visit('https://www.messenger.com/t/ajay.madhukar')
->waitFor('input[type=password]')
->type('email', 'zulfajuniadi@gmail.com')
->type('pass', 'xxxxxxxxx')
->click('#loginbutton')
->waitFor('._5742') // wait for Ajay's Name to load
->assertSee('Ajay Madhukar')
->pause(1000)
->type('._5rpu', $fact) // Type into textarea
->click('a._30yy._38lh._39bl') // submit button
->pause(5000);
;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment