Last active
April 9, 2016 14:15
-
-
Save aik099/95da4fab3ff6a37255782702da34132a to your computer and use it in GitHub Desktop.
QA-Tools usage example for gamer location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use QATools\QATools\HtmlElements\Element\AbstractElementContainer; | |
use QATools\QATools\HtmlElements\Element\Link; | |
use QATools\QATools\HtmlElements\Element\TextBlock; | |
/** | |
* @find-by('css' => 'li.gamer') | |
*/ | |
class GamerElement extends AbstractElementContainer | |
{ | |
/** | |
* Gamer name. | |
* | |
* @var TextBlock | |
* @find-by('class' => 'p.name') | |
*/ | |
private $name; | |
/** | |
* Gamer picture. | |
* | |
* @var Link | |
* @find-by('class' => 'a.picture') | |
*/ | |
private $picture; | |
/** | |
* Gamer points. | |
* | |
* @var TextBlock | |
* @find-by('class' => 'p.points') | |
*/ | |
private $points; | |
/** | |
* Returns name. | |
* | |
* @return string | |
*/ | |
public function getName() | |
{ | |
return $this->name->getText(); | |
} | |
/** | |
* Returns picture. | |
* | |
* @return string | |
*/ | |
public function getPicture() | |
{ | |
return $this->picture->getUrl(); | |
} | |
/** | |
* Returns points. | |
* | |
* @return string | |
*/ | |
public function getPoints() | |
{ | |
return $this->points->getText(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use QATools\QATools\HtmlElements\TypifiedPage; | |
/** | |
* @page-url('/GamersList') | |
*/ | |
class GamersPage extends TypifiedPage | |
{ | |
/** | |
* List of gamers | |
* | |
* @var GamerElement[] | |
*/ | |
private $gamers; | |
/** | |
* Does something with gamers. | |
* | |
* @return void | |
*/ | |
public function processGamers() | |
{ | |
foreach ( $this->gamers as $gamer ) { | |
echo '=========='; | |
echo 'name: ' . $gamer->getName(); | |
echo 'picture: ' . $gamer->getPicture(); | |
echo 'points: ' . $gamer->getPoints(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>List of Gamers</title> | |
</head> | |
<body> | |
<ul class="list-of-gamers"> | |
<li class="gamer"> | |
<p class="name"></p> | |
<a class="picture"></a> | |
<p class="points"></p> | |
</li> | |
<li class="gamer"> | |
<p class="name"></p> | |
<a class="picture"></a> | |
<p class="points"></p> | |
</li> | |
<li class="gamer"> | |
<p class="name"></p> | |
<a class="picture"></a> | |
<p class="points"></p> | |
</li> | |
<li class="gamer"> | |
<p class="name"></p> | |
<a class="picture"></a> | |
<p class="points"></p> | |
</li> | |
</ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was very helpful! Thanks!