Created
January 19, 2017 09:57
-
-
Save zulfajuniadi/f332f5404fc619e353e1ba3ccba5ae2e to your computer and use it in GitHub Desktop.
Facebook Messenger Automation using Laravel Dusk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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', '[email protected]') | |
->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