PHP 및 Symfony를위한 브라우저 테스트 및 웹 스크래핑 라이브러리
Panther는 웹 사이트를 긁어 내고 실제 브라우저를 사용하여 엔드 투 엔드 테스트를 실행하는 편리한 독립형 라이브러리입니다.
Panther는 매우 강력합니다. W3C의 WebDriver 프로토콜을 활용하여 Google Chrome 및 Firefox와 같은 기본 웹 브라우저를 구동합니다.
Panther는 Symfony의 인기있는 Browserkit 및 Domcrawler API를 구현하고 앱을 테스트하는 데 필요한 모든 기능을 포함하기 때문에 사용하기 쉽습니다. Symfony 앱에 대한 기능 테스트를 만든 경우 친숙하게 들릴 것입니다. API가 정확히 동일합니다! Panther는 독립형 라이브러리이므로 Panther는 모든 PHP 프로젝트에서 사용할 수 있습니다.
Panther는 Chrome 또는 Firefox의 로컬 설치를 자동으로 찾아서 발사하므로 컴퓨터에 다른 것을 설치할 필요가 없으므로 Selenium 서버가 필요하지 않습니다!
테스트 모드에서 Panther는 PHP 내장 웹 서버를 사용하여 응용 프로그램을 자동으로 시작합니다. 테스트 또는 웹 스크래핑 시나리오 작성에 집중할 수 있으며 Panther는 다른 모든 것을 처리합니다.
테스트 및 웹 스크래핑 라이브러리와 달리 Panther :
작곡가를 사용하여 프로젝트에 Panther를 설치하십시오. 프로덕션 환경에서 웹 스크래핑이 아닌 테스트를 위해 Panther를 사용하려면 --dev
플래그를 사용하고 싶을 수도 있습니다.
composer req symfony/panther
composer req --dev symfony/panther
Panther는 WebDriver 프로토콜을 사용하여 웹 사이트를 크롤링하는 데 사용되는 브라우저를 제어합니다.
모든 시스템에서 dbrekelmans/browser-driver-installer
사용하여 Chromedriver 및 Geckodriver를 로컬로 설치할 수 있습니다.
composer require --dev dbrekelmans/bdi
vendor/bin/bdi detect drivers
Panther는 drivers/
디렉토리에 저장된 드라이버를 감지하고 사용합니다.
또는 운영 체제의 패키지 관리자를 사용하여 설치할 수 있습니다.
우분투에서 실행 :
apt-get install chromium-chromedriver firefox-geckodriver
Mac에서 홈 브루 사용 :
brew install chromedriver geckodriver
창문에서 초콜릿 사용 :
choco install chromedriver selenium-gecko-driver
마지막으로, 크로메드 리버 (Chromium 또는 Chrome) 및 Geckodriver (Firefox의 경우)를 수동으로 다운로드하여 PATH
나 프로젝트의 drivers/
디렉토리에 넣을 수 있습니다.
Panther를 사용하여 응용 프로그램을 테스트하려는 경우 Panther PHPUnit 확장 등록을 강력히 권장합니다. 엄격하게 필수는 아니지만,이 확장은 성능을 높이고 대화식 디버깅 모드를 사용할 수있게하여 테스트 경험을 크게 향상시킵니다.
PANTHER_ERROR_SCREENSHOT_DIR
환경 변수와 함께 확장을 사용하는 경우, 실패 또는 오류 (클라이언트가 생성 된 후)를 사용하는 Panther 클라이언트를 사용하여 테스트하면 스크린 샷이 자동으로 가져와 디버깅에 도움이됩니다.
Panther Extension을 등록하려면 phpunit.xml.dist
에 다음 줄을 추가하십시오.
<!-- phpunit.xml.dist -->
< extensions >
< extension class = " SymfonyComponentPantherServerExtension " />
</ extensions >
확장이 없으면 Panther가 테스트중인 애플리케이션을 제공하기 위해 사용하는 웹 서버가 주문형으로 시작되고 tearDownAfterClass()
호출 될 때 중지됩니다. 반면에 확장이 등록되면 웹 서버는 마지막 테스트 후에 만 중지됩니다.
<?php
use Symfony Component Panther Client ;
require __DIR__ . ' /vendor/autoload.php ' ; // Composer's autoloader
$ client = Client :: createChromeClient ();
// Or, if you care about the open web and prefer to use Firefox
$ client = Client :: createFirefoxClient ();
$ client -> request ( ' GET ' , ' https://api-platform.com ' ); // Yes, this website is 100% written in JavaScript
$ client -> clickLink ( ' Getting started ' );
// Wait for an element to be present in the DOM (even if hidden)
$ crawler = $ client -> waitFor ( ' #installing-the-framework ' );
// Alternatively, wait for an element to be visible
$ crawler = $ client -> waitForVisibility ( ' #installing-the-framework ' );
echo $ crawler -> filter ( ' #installing-the-framework ' )-> text ();
$ client -> takeScreenshot ( ' screen.png ' ); // Yeah, screenshot!
PantherTestCase
클래스를 사용하면 E2E 테스트를 쉽게 작성할 수 있습니다. 내장 된 PHP 웹 서버를 사용하여 자동으로 앱을 시작하고 Panther를 사용하여 크롤링 할 수 있습니다. 익숙한 모든 테스트 도구를 제공하기 위해 PhPunit의 TestCase
확장합니다.
Symfony 응용 프로그램을 테스트하는 경우 PantherTestCase
자동으로 WebTestCase
클래스를 확장합니다. 이는 기능 테스트를 쉽게 만들 수 있으며, 이는 응용 프로그램의 커널을 직접 실행하고 기존 서비스에 액세스 할 수 있습니다. 이 경우 Symfony가 Panther와 함께 제공 한 모든 크롤러 테스트 어설 션을 사용할 수 있습니다.
<?php
namespace App Tests ;
use Symfony Component Panther PantherTestCase ;
class E2eTest extends PantherTestCase
{
public function testMyApp (): void
{
$ client = static :: createPantherClient (); // Your app is automatically started using the built-in web server
$ client -> request ( ' GET ' , ' /mypage ' );
// Use any PHPUnit assertion, including the ones provided by Symfony
$ this -> assertPageTitleContains ( ' My Title ' );
$ this -> assertSelectorTextContains ( ' #main ' , ' My body ' );
// Or the one provided by Panther
$ this -> assertSelectorIsEnabled ( ' .search ' );
$ this -> assertSelectorIsDisabled ( ' [type="submit"] ' );
$ this -> assertSelectorIsVisible ( ' .errors ' );
$ this -> assertSelectorIsNotVisible ( ' .loading ' );
$ this -> assertSelectorAttributeContains ( ' .price ' , ' data-old-price ' , ' 42 ' );
$ this -> assertSelectorAttributeNotContains ( ' .price ' , ' data-old-price ' , ' 36 ' );
// Use waitForX methods to wait until some asynchronous process finish
$ client -> waitFor ( ' .popin ' ); // wait for element to be attached to the DOM
$ client -> waitForStaleness ( ' .popin ' ); // wait for element to be removed from the DOM
$ client -> waitForVisibility ( ' .loader ' ); // wait for element of the DOM to become visible
$ client -> waitForInvisibility ( ' .loader ' ); // wait for element of the DOM to become hidden
$ client -> waitForElementToContain ( ' .total ' , ' 25 € ' ); // wait for text to be inserted in the element content
$ client -> waitForElementToNotContain ( ' .promotion ' , ' 5% ' ); // wait for text to be removed from the element content
$ client -> waitForEnabled ( ' [type="submit"] ' ); // wait for the button to become enabled
$ client -> waitForDisabled ( ' [type="submit"] ' ); // wait for the button to become disabled
$ client -> waitForAttributeToContain ( ' .price ' , ' data-old-price ' , ' 25 € ' ); // wait for the attribute to contain content
$ client -> waitForAttributeToNotContain ( ' .price ' , ' data-old-price ' , ' 25 € ' ); // wait for the attribute to not contain content
// Let's predict the future
$ this -> assertSelectorWillExist ( ' .popin ' ); // element will be attached to the DOM
$ this -> assertSelectorWillNotExist ( ' .popin ' ); // element will be removed from the DOM
$ this -> assertSelectorWillBeVisible ( ' .loader ' ); // element will be visible
$ this -> assertSelectorWillNotBeVisible ( ' .loader ' ); // element will not be visible
$ this -> assertSelectorWillContain ( ' .total ' , ' €25 ' ); // text will be inserted in the element content
$ this -> assertSelectorWillNotContain ( ' .promotion ' , ' 5% ' ); // text will be removed from the element content
$ this -> assertSelectorWillBeEnabled ( ' [type="submit"] ' ); // button will be enabled
$ this -> assertSelectorWillBeDisabled ( ' [type="submit"] ' ); // button will be disabled
$ this -> assertSelectorAttributeWillContain ( ' .price ' , ' data-old-price ' , ' €25 ' ); // attribute will contain content
$ this -> assertSelectorAttributeWillNotContain ( ' .price ' , ' data-old-price ' , ' €25 ' ); // attribute will not contain content
}
}
이 테스트를 실행하려면 :
bin/phpunit tests/E2eTest.php
Panther는 또한 다른 Browserkit 기반 Client
및 Crawler
의 구현에 즉시 액세스 할 수 있습니다. Panther의 기본 클라이언트와 달리 이러한 대체 클라이언트는 JavaScript, CSS 및 스크린 샷 캡처를 지원하지 않지만 매우 빠릅니다 !
두 개의 대체 클라이언트를 사용할 수 있습니다.
WebTestCase
에서 제공하는 Symfony 커널을 직접 조작합니다. 사용 가능한 가장 빠른 클라이언트이지만 Symfony 앱에서만 사용할 수 있습니다.재미있는 부분은 3 명의 클라이언트가 정확히 동일한 API를 구현하므로 적절한 공장 방법을 호출하여 전환 할 수 있으므로 모든 단일 테스트 사례에 맞는 트레이드 오프가 적용됩니다 (JavaScript가 필요합니까? 외부 SSO 서버로 인증해야합니까?
이 클라이언트의 인스턴스를 검색하는 방법은 다음과 같습니다.
<?php
namespace App Tests ;
use Symfony Component Panther PantherTestCase ;
use Symfony Component Panther Client ;
class E2eTest extends PantherTestCase
{
public function testMyApp (): void
{
$ symfonyClient = static :: createClient (); // A cute kitty: Symfony's functional test tool
$ httpBrowserClient = static :: createHttpBrowserClient (); // An agile lynx: HttpBrowser
$ pantherClient = static :: createPantherClient (); // A majestic Panther
$ firefoxClient = static :: createPantherClient ([ ' browser ' => static :: FIREFOX ]); // A splendid Firefox
// Both HttpBrowser and Panther benefits from the built-in HTTP server
$ customChromeClient = Client :: createChromeClient ( null , null , [], ' https://example.com ' ); // Create a custom Chrome client
$ customFirefoxClient = Client :: createFirefoxClient ( null , null , [], ' https://example.com ' ); // Create a custom Firefox client
$ customSeleniumClient = Client :: createSeleniumClient ( ' http://127.0.0.1:4444/wd/hub ' , null , ' https://example.com ' ); // Create a custom Selenium client
// When initializing a custom client, the integrated web server IS NOT started automatically.
// Use PantherTestCase::startWebServer() or WebServerManager if you want to start it manually.
// enjoy the same API for the 3 felines
// $*client->request('GET', '...')
$ kernel = static :: createKernel (); // If you are testing a Symfony app, you also have access to the kernel
// ...
}
}
Panther는 Mercure, WebSocket 및 유사한 기술을 사용하는 실시간 기능으로 응용 프로그램을 테스트하는 편리한 방법을 제공합니다.
PantherTestCase::createAdditionalPantherClient()
서로 상호 작용할 수있는 추가로 분리 된 브라우저를 만듭니다. 예를 들어, 여러 사용자가 동시에 연결된 채팅 응용 프로그램을 테스트하는 데 유용 할 수 있습니다.
<?php
use Symfony Component Panther PantherTestCase ;
class ChatTest extends PantherTestCase
{
public function testChat (): void
{
$ client1 = self :: createPantherClient ();
$ client1 -> request ( ' GET ' , ' /chat ' );
// Connect a 2nd user using an isolated browser and say hi!
$ client2 = self :: createAdditionalPantherClient ();
$ client2 -> request ( ' GET ' , ' /chat ' );
$ client2 -> submitForm ( ' Post message ' , [ ' message ' => ' Hi folks ? ' ]);
// Wait for the message to be received by the first client
$ client1 -> waitFor ( ' .message ' );
// Symfony Assertions are always executed in the **primary** browser
$ this -> assertSelectorTextContains ( ' .message ' , ' Hi folks ? ' );
}
}
필요한 경우 Panther를 사용하여 콘솔의 내용에 액세스 할 수 있습니다.
<?php
use Symfony Component Panther PantherTestCase ;
class ConsoleTest extends PantherTestCase
{
public function testConsole (): void
{
$ client = self :: createPantherClient (
[],
[],
[
' capabilities ' => [
' goog:loggingPrefs ' => [
' browser ' => ' ALL ' , // calls to console.* methods
' performance ' => ' ALL ' , // performance data
],
],
]
);
$ client -> request ( ' GET ' , ' / ' );
$ consoleLogs = $ client -> getWebDriver ()-> manage ()-> getLog ( ' browser ' ); // console logs
$ performanceLogs = $ client -> getWebDriver ()-> manage ()-> getLog ( ' performance ' ); // performance logs
}
}
필요한 경우 chromedriver
Binary로 전달하도록 인수를 구성 할 수 있습니다.
<?php
use Symfony Component Panther PantherTestCase ;
class MyTest extends PantherTestCase
{
public function testLogging (): void
{
$ client = self :: createPantherClient (
[],
[],
[
' chromedriver_arguments ' => [
' --log-path=myfile.log ' ,
' --log-level=DEBUG '
],
]
);
$ client -> request ( ' GET ' , ' / ' );
}
}
Client::ping()
메소드를 사용하여 WebDriver 연결이 여전히 활성화되어 있는지 확인하십시오 (장기 실행 작업에 유용).
Panther는 인기있는 라이브러리의 API를 구현하기 때문에 이미 광범위한 문서가 있습니다.
Client
클래스의 경우 Browserkit 문서를 읽으십시오Crawler
클래스의 경우 Domcrawler 문서를 읽으십시오다음 환경 변수는 Panther의 동작을 변경하도록 설정할 수 있습니다.
PANTHER_NO_HEADLESS
: 브라우저의 헤드리스 모드를 비활성화하려면 (테스트 창을 표시하고 디버그에 유용합니다)PANTHER_WEB_SERVER_DIR
: 프로젝트의 문서 루트를 변경하려면 (기본값을 ./public/
으로, 상대 경로 는 ./
)PANTHER_WEB_SERVER_PORT
: 웹 서버 포트를 변경하려면 (기본값은 9080
으로)PANTHER_WEB_SERVER_ROUTER
: 각 HTTP 요청의 시작시 실행되는 웹 서버 라우터 스크립트를 사용하려면PANTHER_EXTERNAL_BASE_URI
: 외부 웹 서버를 사용하려면 (PHP 내장 웹 서버가 시작되지 않음)PANTHER_APP_ENV
: php 앱을 실행하는 웹 서버로 전달 된 APP_ENV
변수를 재정의하려면PANTHER_ERROR_SCREENSHOT_DIR
: 실패/오류 스크린 샷에 대한 기본 디렉토리를 설정하려면 (예 ./var/error-screenshots
error-screenshots)PANTHER_DEVTOOLS
: 브라우저의 개발 도구를 전환하려면 (기본 enabled
, 디버그에 유용함)PANTHER_ERROR_SCREENSHOT_ATTACH
: Junit Attachment 형식에서 출력을 테스트하기 위해 위에서 언급 한 스크린 샷을 추가하려면 내장 웹 서버에서 사용하는 호스트 및/또는 포트를 변경하려면 hostname
과 port
createPantherClient()
메소드의 $options
매개 변수로 전달하십시오.
// ...
$ client = self :: createPantherClient ([
' hostname ' => ' example.com ' , // Defaults to 127.0.0.1
' port ' => 8080 , // Defaults to 9080
]);
PANTHER_NO_SANDBOX
: Chrome의 샌드 박스를 비활성화하려면 (안전하지 않지만 컨테이너에서 Panther를 사용할 수 있음)PANTHER_CHROME_ARGUMENTS
: 크롬 인수를 사용자 정의합니다. 완전히 사용자 정의하려면 PANTHER_NO_HEADLESS
설정해야합니다.PANTHER_CHROME_BINARY
: 다른 google-chrome
바이너리를 사용합니다 PANTHER_FIREFOX_ARGUMENTS
: Firefox 인수를 사용자 정의합니다. 완전히 사용자 정의하려면 PANTHER_NO_HEADLESS
설정해야합니다.PANTHER_FIREFOX_BINARY
: 다른 firefox
바이너리를 사용합니다 사양에 따르면 WebDriver 구현은 기본적으로 표시된 텍스트 만 반환합니다. head
태그 (예 : title
)를 필터링하면 메소드 text()
빈 문자열을 반환합니다. 메소드 html()
사용하여 태그 자체를 포함하여 태그의 전체 내용을 얻으십시오.
Panther는 실패 후 테스트 스위트에서 일시 중지 할 수 있습니다. 웹 브라우저를 통해 문제를 조사하는 데 정말 감사의 시간이 걸립니다. 이 모드를 활성화하려면 헤드리스 모드가없는 --debug
phpunit 옵션이 필요합니다.
$ PANTHER_NO_HEADLESS=1 bin/phpunit --debug
Test 'AppAdminTest::testLogin' started
Error: something is wrong.
Press enter to continue...
대화식 모드를 사용하려면 PHPUnit 확장을 등록 해야합니다 .
때로는 내장 PHP One을 시작하는 대신 기존 웹 서버 구성을 재사용하는 것이 편리합니다. 이렇게하려면 external_base_uri
옵션을 설정하십시오.
<?php
namespace App Tests ;
use Symfony Component Panther PantherTestCase ;
class E2eTest extends PantherTestCase
{
public function testMyApp (): void
{
$ pantherClient = static :: createPantherClient ([ ' external_base_uri ' => ' https://localhost ' ]);
// the PHP integrated web server will not be started
}
}
PHP/Symfony 응용 프로그램은 여러 다른 도메인 이름을 제공 할 수 있습니다.
Panther는 성능을 향상시키기 위해 테스트간에 클라이언트를 메모리로 저장하므로 다른 도메인 이름에 대해 Panther를 사용하여 여러 테스트를 작성하면 별도의 프로세스로 테스트를 실행해야합니다.
이를 위해서는 a기 @runInSeparateProcess
PHPUnit 주석을 사용할 수 있습니다.
ℹ 참고 : Panther는 각 테스트에서 서버를 시작하고 중지 할 필요가 없기 때문에 external_base_uri
옵션을 사용하고 백그라운드에서 자신의 웹 서버를 시작하는 것이 정말 편리합니다. Symfony Cli는 빠르고 쉬운 방법이 될 수 있습니다.
다음은 Client가 사용하는 도메인 이름을 결정하기 위해 external_base_uri
옵션을 사용하는 예입니다.
<?php
namespace App Tests ;
use Symfony Component Panther PantherTestCase ;
class FirstDomainTest extends PantherTestCase
{
/**
* @runInSeparateProcess
*/
public function testMyApp (): void
{
$ pantherClient = static :: createPantherClient ([
' external_base_uri ' => ' http://mydomain.localhost:8000 ' ,
]);
// Your tests
}
}
<?php
namespace App Tests ;
use Symfony Component Panther PantherTestCase ;
class SecondDomainTest extends PantherTestCase
{
/**
* @runInSeparateProcess
*/
public function testMyApp (): void
{
$ pantherClient = static :: createPantherClient ([
' external_base_uri ' => ' http://anotherdomain.localhost:8000 ' ,
]);
// Your tests
}
}
프록시 서버를 사용하려면 다음 환경 변수를 설정하십시오. PANTHER_CHROME_ARGUMENTS='--proxy-server=socks://127.0.0.1:9050'
크롬이 유효하지 않고 자체 서명 된 인증서를 수락하도록 강요하려면 다음 환경 변수를 설정하십시오. PANTHER_CHROME_ARGUMENTS='--ignore-certificate-errors'
옵션은 안전하지 않습니다 . 겉옷).
Firefox의 경우 다음과 같이 클라이언트를 인스턴스화하십시오.
$ client = Client :: createFirefoxClient ( null , null , [ ' capabilities ' => [ ' acceptInsecureCerts ' => true ]]);
다음은 Chrome과 Firefox로 Panther를 실행할 수있는 최소 Docker 이미지입니다.
FROM php:alpine
# Chromium and ChromeDriver
ENV PANTHER_NO_SANDBOX 1
# Not mandatory, but recommended
ENV PANTHER_CHROME_ARGUMENTS= '--disable-dev-shm-usage'
RUN apk add --no-cache chromium chromium-chromedriver
# Firefox and GeckoDriver (optional)
ARG GECKODRIVER_VERSION=0.28.0
RUN apk add --no-cache firefox libzip-dev;
docker-php-ext-install zip
RUN wget -q https://github.com/mozilla/geckodriver/releases/download/v$GECKODRIVER_VERSION/geckodriver-v$GECKODRIVER_VERSION-linux64.tar.gz;
tar -zxf geckodriver-v$GECKODRIVER_VERSION-linux64.tar.gz -C /usr/bin;
rm geckodriver-v$GECKODRIVER_VERSION-linux64.tar.gz
docker build . -t myproject
docker run -it -v "$PWD":/srv/myproject -w /srv/myproject myproject bin/phpunit
Panther는 Github 액션으로 상자 밖으로 작동합니다. 다음은 Panther 테스트를 실행할 최소 .github/workflows/panther.yml
파일입니다.
name : Run Panther tests
on : [ push, pull_request ]
jobs :
tests :
runs-on : ubuntu-latest
steps :
- uses : actions/checkout@v2
- name : Install dependencies
run : composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name : Run test suite
run : bin/phpunit
Chrome Addon을 추가하면 Panther는 Travis CI와 함께 상자 밖으로 작동합니다. Panther 테스트를 실행하려면 .travis.yml
파일은 다음과 같습니다.
language : php
addons :
# If you don't use Chrome, or Firefox, remove the corresponding line
chrome : stable
firefox : latest
php :
- 8.0
script :
- bin/phpunit
다음은 gitlab ci를 사용하여 Panther 테스트를 실행하기위한 최소 .gitlab-ci.yml
파일입니다.
image : ubuntu
before_script :
- apt-get update
- apt-get install software-properties-common -y
- ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
- apt-get install curl wget php php-cli php7.4 php7.4-common php7.4-curl php7.4-intl php7.4-xml php7.4-opcache php7.4-mbstring php7.4-zip libfontconfig1 fontconfig libxrender-dev libfreetype6 libxrender1 zlib1g-dev xvfb chromium-chromedriver firefox-geckodriver -y -qq
- export PANTHER_NO_SANDBOX=1
- export PANTHER_WEB_SERVER_PORT=9080
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php composer-setup.php --install-dir=/usr/local/bin --filename=composer
- php -r "unlink('composer-setup.php');"
- composer install
test :
script :
- bin/phpunit
Panther는 Google Chrome이 설치되는 한 Appveyor와 함께 상자 밖으로 작동합니다. Panther 테스트를 실행하기위한 최소 appveyor.yml
파일은 다음과 같습니다.
build : false
platform : x86
clone_folder : c:projectsmyproject
cache :
- ' %LOCALAPPDATA%Composerfiles '
install :
- ps : Set-Service wuauserv -StartupType Manual
- cinst -y php composer googlechrome chromedriver firfox selenium-gecko-driver
- refreshenv
- cd c:toolsphp80
- copy php.ini-production php.ini /Y
- echo date.timezone="UTC" >> php.ini
- echo extension_dir=ext >> php.ini
- echo extension=php_openssl.dll >> php.ini
- echo extension=php_mbstring.dll >> php.ini
- echo extension=php_curl.dll >> php.ini
- echo memory_limit=3G >> php.ini
- cd %APPVEYOR_BUILD_FOLDER%
- composer install --no-interaction --no-progress
test_script :
- cd %APPVEYOR_BUILD_FOLDER%
- php binphpunit
LiipFunctionalTestBundle과 같은 다른 테스트 도구와 함께 Panther를 사용하려면 다른 기본 클래스를 사용해야하는 경우 Panther가 귀하를 다루었습니다. 그것은 SymfonyComponentPantherPantherTestCaseTrait
를 제공하며이를 사용하여 기존 테스트 인프라를 향상시킬 수 있습니다.
<?php
namespace App Tests Controller ;
use Liip FunctionalTestBundle Test WebTestCase ;
use Symfony Component Panther PantherTestCaseTrait ;
class DefaultControllerTest extends WebTestCase
{
use PantherTestCaseTrait ; // this is the magic. Panther is now available.
public function testWithFixtures (): void
{
$ this -> loadFixtures ([]); // load your fixtures
$ client = self :: createPantherClient (); // create your panther client
$ client -> request ( ' GET ' , ' / ' );
}
}
다음과 같은 기능은 현재 지원되지 않습니다.
DOMElement
인스턴스를 반환하는 방법 (이 라이브러리는 내부적으로 WebDriverElement
사용하기 때문에)풀 요청은 나머지 간격을 채우는 것을 환영합니다!
Bootstrap 5를 사용하는 경우 테스트에 문제가있을 수 있습니다. 부트 스트랩 5는 스크롤 효과를 구현하여 팬더를 오도하는 경향이 있습니다.
이 문제를 해결하기 위해 스타일 파일에서 부트 스트랩 5 $ 활성화-스크롤 변수를 False 로 설정 하여이 효과를 비활성화하는 것이 좋습니다.
$enable-smooth-scroll : false;
많은 야생 고양이 종들이 크게 위협 받고 있습니다. 이 소프트웨어가 마음에 들면 Panthera 조직에 기부하여 (실제) Panthers를 저장하십시오.
Kévin Dunglas에 의해 만들어졌습니다. les-tilleuls.coop가 후원합니다.
Panther는 PHP Webdriver 및 기타 여러 Foss 라이브러리 위에 구축되었습니다. JavaScript 용 WebDriver 기반 테스트 도구 인 NightWatch.js에서 영감을 얻었습니다.