public function testRedirect()
 {
     $session = new CrawlerSession(new Crawler());
     $session->open('/old-blog');
     $this->assertEquals('Blog Index', $session->get('h1')->getText());
     $this->assertEquals('/blog', $session->get('meta[type="description"]')->getattribute('content'));
     $this->assertEquals('/blog', (string) $session->getUri());
 }
 public function testSimple()
 {
     $index = new Crawler('index.html');
     $session = new CrawlerSession($index);
     $a = $session->get('.subnav li a:visible(true):text("Subpage 2")');
     $this->assertEquals('Subpage Title 2', $a->getAttribute('title'));
     $session->get('#form')->with(function ($form) use($index) {
         $this->assertEquals('form', $form->getAttribute('id'));
         $form->getField('Enter Email:value("*****@*****.**")')->with(function ($email) {
             $this->assertEquals('*****@*****.**', $email->getValue());
         });
         $form->setField('Enter Name', 'Other thing');
         $name = $form->getField('Enter Name');
         $this->assertMatchesSelector('input[value="Other thing"]', $index->getElement($name->getId()), 'Should set a text input value');
         $form->setFieldFile('Logo', '/var/usr/example.jpg');
         $file = $form->getField('file');
         $this->assertMatchesSelector('input[value="/var/usr/example.jpg"]', $index->getElement($file->getId()), 'Should set a file input value');
         $label = $form->getLabel('Gender Male');
         $this->assertMatchesSelector('label[for="gender-1"]', $index->getElement($label->getId()), 'Should find the correct label by text content');
     });
 }