Hi I am a facebook Webdriver newbie. I need help on getting HTML source of an AJAX page.
Here is my expected results:
$first == HTML source of the 1st page.
$second == HTML source of the 2nd page.
$third == HTML source of the 3rd page.
But my Output:
$first == HTML source of the 1st page.
$second == $first
$third == HTML source of the 2nd page.
However, I could get the HTML source of the 2nd page when I landed on the 3rd page. I don't know why I can not get the current HTML on Current page.
Please Help!
Here is my code:
<?php
$host = 'http://localhost:4444/wd/hub';
$capabilities = DesiredCapabilities::firefox();
$driver = RemoteWebDriver::create($host, $capabilities, 5000);
// Openning page
$driver->get('https://careers.yahoo.com/?global=1');
// Click 'Search'
$driver->findElement(WebDriverBy::className('yellow-submit'))->click();
// Wait until Ajax part loaded
$driver->wait(40)->until(
WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(
WebDriverBy::className('actions-container')
));
// Print HTML of the 1st page
$first = $driver->getPageSource();
print_r($first);
// go to 2nd page
$driver->findElement(WebDriverBy::id('next'))->click();
// Wait until the 2nd page is loaded
$driver->wait(40)->until(
WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(
WebDriverBy::className('actions-container')
));
// Print HTML of the 2nd page
$second = $driver->getPageSource();
print_r($second);
// go to 3rd page
$driver->findElement(WebDriverBy::id('next'))->click();
// Wait until the 3rd page is loaded
$driver->wait(40)->until(
WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(
WebDriverBy::className('actions-container')
));
// Print HTML of the 3rd page
$second = $driver->getPageSource();
print_r($third);
$driver->quit();