Created
April 24, 2017 15:35
-
-
Save ekos/dc8ef6388540fd7c026a197b0ea52572 to your computer and use it in GitHub Desktop.
This file contains 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 | |
require_once dirname(__FILE__) . "/phpwebdriver/WebDriver.php"; | |
require_once dirname(__FILE__) . "/phpwebdriver/LocatorStrategy.php"; | |
$URL = "http://example.com/"; | |
$webdriver = new WebDriver("localhost", "4444"); | |
$webdriver->connect("firefox"); | |
//サイトアクセス | |
$webdriver->get($URL); | |
//More information...をクリック | |
$informationElement = $webdriver->findElementBy(LocatorStrategy::xpath, "/html/body/div/p[2]/a"); | |
$informationElement->click(); | |
sleep(2);//アクセスに時間がかかるので、待機する | |
//スクリーンショットの取得 | |
file_put_contents('example.png', $webdriver->getScreenshot()); | |
//ページソースの取得 | |
file_put_contents('example.html', $webdriver->getPageSource()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment