Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Symfony Panther - an introduction and review

1768d238acf404dadd501ba424d65bfd?s=47 dknx01
February 27, 2019

Symfony Panther - an introduction and review

A quick introductin and review about the E2E testing tool Symfony Panther.

Presented at Symfony User Group Berlin

1768d238acf404dadd501ba424d65bfd?s=128

dknx01

February 27, 2019
Tweet

Transcript

  1. None
  2. Symfony Panther an introduction and review Symfony User Group Berlin

    Erik Witthauer
  3. About me Erik Witthauer PHP developer for > 10 years

    Twitter: ewnx01 Web aka: dknx01 Speakerdeck: speackerdeck.com/dknx01 currently work: FTI
  4. How to test a web application

  5. How to test a web application with(out) PHP • use

    external E2E tools • use monkeys (testing everything manual) • use PHPUnit with ◦ WebTestCase ◦ BrowserKit, DomCrawler ◦ CssSelector • Behat • other testing frameworks
  6. What about ...? Behat • uses CssSelection • hard to

    handle Javascript (loading) • sees “everything” • does not behave like a real browser WebTestCase • use local setup (booting Kernel) • hard to handle Javascript (loading) • sees “everything” • does not behave like a real browser
  7. What about ...? Goutte • uses CssSelection • no Javascript

    handling • sees “everything” • does not behave like a real browser
  8. How to test a web application with(out) PHP • Problems:

    ◦ detection of hidden elements, by CSS ◦ JavaScript changes or error prevent loading ◦ browser blocking (XSS ...)
  9. None
  10. Solution: Symfony Panther

  11. What is Symfony Panther? • a Browser Testing and Web

    Scrapping Library for PHP • library for E2E testing • executes a real browser (with full JS and CSS support) • build on top of Facebook PHP WebDriver and WebDriver protocol • supports JavaScript execution • implements BrowserKit API • standalone lib
  12. What is Symfony Panther? • shipped with ChromeDriver binaries •

    uses local Chrome • runs headless • compatibles with Selenium server, remote testing services (e.g. BrowserStack, SauceLabs) • experimental GeckoDriver • uses builtin PHP web server
  13. What is Symfony Panther? • can use external based URLs

    (any URL) • can take screenshots • injecting and execute JavaScript on the fly (even asynchrone) • simulate different resolutions (responsive testing)
  14. How to use it class BlogPostControllerTest extends WebTestCase { public

    function testSeeHeadline() { $client = static::createClient(); // Here goes the Code } } class BlogPostControllerPantherTest extends PantherTestCase { public function testSeeHeadline() { $client = static::createPantherClient(); // Here goes the Code } }
  15. Demo time

  16. Links https://symfony.com/blog/introducing-symfony-panther-a-browser-testing-and-web -scrapping-library-for-php https://github.com/symfony/panther https://www.youtube.com/watch?v=bpKUApk8cNw (SymfonyLive London 2018 - Kévin

    Dunglas)
  17. Question and talk time

  18. End