The phpwd library is Selenium WebDriver client in PHP.
You can install via composer.
composer require hgsgtk/phpwdFor example, it can be used like this:
use Phpwd\LocatorStrategy;
use Phpwd\Webdriver;
$driver = new Webdriver();
try {
// Open browser by webdriver(especially chromedriver)
$browser = $driver->openBrowser();
// Go to example.com
$browser->navigateTo('https://example.com/');
sleep(1); // To demonstration
// Find the text of title
$titleElement = $browser->findElement(LocatorStrategy::TagName, 'h1');
$titleText = $titleElement->getText();
$this->assertSame('Example Domain', $titleText);
// Click the link
$linkElement = $browser->findElement(LocatorStrategy::LinkText, 'More information...');
$linkElement->click();
sleep(1); // To demonstration
// Confirm to move IANA
$titleElement = $browser->findElement(LocatorStrategy::TagName, 'h1');
$titleText = $titleElement->getText();
$this->assertSame('IANA-managed Reserved Domains', $titleText);
// Move to RFC 2606
$linkElement = $browser->findElement(LocatorStrategy::Css, '[href="/go/rfc2606"]');
$linkElement->click();
sleep(1); // To demonstration
$url = $browser->getCurrentUrl();
$this->assertSame('https://www.rfc-editor.org/rfc/rfc2606.html', $url);
} finally {
$driver->closeBrowser();
}To control a browser, you need to start a remote end (server), which will listen to the commands sent from this library. By using the included docker-compose.yml, chrome driver can be used immediately.
make set-localYou can run tests by using Docker environment.
make run-tests