Browse files

support content-type meta tag with SeleniumDriver

  • Loading branch information...
1 parent e41e70a commit 2e5672ab86b3be34127c50c09954a3159c2febe1 @everzet everzet committed May 25, 2012
Showing with 15 additions and 2 deletions.
  1. +1 −1 src/Behat/Mink/Driver/Goutte/Client.php
  2. +14 −1 src/Behat/Mink/Driver/SeleniumDriver.php
View
2 src/Behat/Mink/Driver/Goutte/Client.php
@@ -32,7 +32,7 @@ protected function createResponse(GuzzleResponse $response)
$contentType = $response->getContentType();
if (!$contentType || false === strpos($contentType, 'charset=')) {
- if (preg_match('/\<meta[^\>]+charset *= *["\']?([a-zA-Z\-0-9]+)/', $body, $matches)) {
+ if (preg_match('/\<meta[^\>]+charset *= *["\']?([a-zA-Z\-0-9]+)/i', $body, $matches)) {
$contentType .= ';charset='.$matches[1];
}
}
View
15 src/Behat/Mink/Driver/SeleniumDriver.php
@@ -7,6 +7,8 @@
Behat\Mink\Exception\DriverException,
Behat\Mink\Exception\UnsupportedDriverActionException;
+use Symfony\Component\DomCrawler\Crawler;
+
use Selenium\Client as SeleniumClient,
Selenium\Locator as SeleniumLocator,
Selenium\Exception as SeleniumException;
@@ -627,7 +629,18 @@ public function dragTo($sourceXpath, $destinationXpath)
*/
private function getCrawler()
{
- return new \Symfony\Component\DomCrawler\Crawler('<html>'.$this->browser->getHtmlSource().'</html>');
+ $content = '<html>'.$this->browser->getHtmlSource().'</html>';
+
+ $contentType = null;
+ // get content-type from meta tag
+ if (preg_match('/\<meta[^\>]+charset *= *["\']?([a-zA-Z\-0-9]+)/i', $content, $matches)) {
+ $contentType = 'text/html;charset='.$matches[1];
+ }
+
+ $crawler = new Crawler();
+ $crawler->addContent($content, $contentType);
+
+ return $crawler;
}
/**

0 comments on commit 2e5672a

Please sign in to comment.