Codeception has no method to grab href of the link because it too special case, but you can define your own action in WebHelper class to grab href using Mink API. Read more about Modules and Helpers.
Here is example of action that grabs href of a link:
public function grabHref($locator)
{
$webDriver = $this->getModule('Selenium2');
$link = $webDriver->session->getPage()->findLink($locator);
if ($link) {
return $link->getAttribute('href');
}
$this->fail("Link '{$locator}' not found");
}
Place this function in _helpers/WebHelper.php file, then enable WebHelper module in your test suit config:
class_name: WebGuy
modules:
enabled: [Selenium2, WebHelper]
Then run codecept build
to rebuild your WebGuy class.
Now, you can use your grabHref action in your cept/cest files:
$I = new WebGuy($scenario);
$I->wantTo('Grab Href');
$I->amOnPage('/');
$href = $I->grabHref('Link text or ID or Title');