public function testSet() { $browser = $this->getBrowser(); $browser->open($this->getUrl('cookies.php')); $browser->getCookies()->set('foo', 'bar'); $browser->refresh(); $this->assertEquals('bar', $browser->element(By::css('td[data-cookie="foo"]'))->getText()); }
public function testElementMoveTo() { $browser = $this->getBrowser(); $browser->open($this->getUrl('mouse.php')); $this->assertNotContains('You see this text because of hover', $browser->getText()); $browser->element(By::css('h1'))->moveTo(); $browser->element(By::css('.hover-wrapper .title'))->moveTo(); $this->assertContains('You see this text because of hover', $browser->getText()); }
public function testEquals() { $browser = $this->getBrowser()->open($this->getUrl('index.php')); $a = $browser->element(By::id('danger-zone')); $b = $browser->element(By::css('#danger-zone')); $c = $browser->element(By::id('hidden-element')); $this->assertTrue($a->equals($a)); $this->assertTrue($a->equals($b)); $this->assertTrue($b->equals($a)); $this->assertFalse($a->equals($c)); $this->assertFalse($c->equals($a)); }
/** * Converts a text selector to a By object. * * Tries to find magic expressions (css=#foo, xpath=//div[@id="foo"], id=foo, name=q, class=active). * * @return By|string returns a By instance when magic matched, the string otherwise */ protected function parseSelector($text) { if (0 === strpos($text, 'id=')) { return By::id(substr($text, 3)); } if (0 === strpos($text, 'xpath=')) { return By::xpath(substr($text, 6)); } if (0 === strpos($text, 'css=')) { return By::css(substr($text, 4)); } if (0 === strpos($text, 'name=')) { return By::name(substr($text, 5)); } if (0 === strpos($text, 'class=')) { return By::className(substr($text, 6)); } return $text; }