Skip to content

Commit

Permalink
catch exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Mestan committed Aug 21, 2017
1 parent 44c8a9d commit d5625d4
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions src/HighlightCeption.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Codeception\Module;

use Exception;
use Codeception\Module;
use Codeception\TestInterface;
use Codeception\Exception\ConfigurationException;
Expand Down Expand Up @@ -149,12 +150,16 @@ public function clickWithRightButton($cssOfXPath = null, $offsetX = null, $offse
*/
private function highlightText($text)
{
$this->loadJQuery();
$this->debug('[Highlight Text] ' . $text);
$this->webDriverModule->executeJs('jQuery(document).ready(function (){
jQuery("body").highlight("' . $text . '");
' . sprintf('jQuery(".highlight").css(%s);', $this->cssStyle) . '
});');
try {
$this->loadJQuery();
$this->debug('[Highlight Text] ' . $text);
$this->webDriverModule->executeJs('jQuery(document).ready(function (){
jQuery("body").highlight("' . $text . '");
' . sprintf('jQuery(".highlight").css(%s);', $this->cssStyle) . '
});');
} catch(Exception $e) {
$this->debug(sprintf("[Highlight Exception] %s \n%s", $e->getMessage(), $e->getTraceAsString()));
}
}

/**
Expand All @@ -164,17 +169,21 @@ private function highlightText($text)
*/
private function highlightElement($selector)
{
$locator = $this->getSelector($selector);
if ($locator) {
$this->loadJQuery();
if (Locator::isXPath($locator)) {
$this->loadJQueryXPath();
$this->debug('[Highlight XPath] ' . Locator::humanReadableString($locator));
$this->webDriverModule->executeJs(sprintf('jQuery(document).xpath("%s").css(%s);', addslashes($locator), $this->cssStyle));
} else {
$this->debug('[Highlight Selector] ' . Locator::humanReadableString($locator));
$this->webDriverModule->executeJs(sprintf('jQuery("%s").css(%s);', addslashes($locator), $this->cssStyle));
try {
$locator = $this->getSelector($selector);
if ($locator) {
$this->loadJQuery();
if (Locator::isXPath($locator)) {
$this->loadJQueryXPath();
$this->debug('[Highlight XPath] ' . Locator::humanReadableString($locator));
$this->webDriverModule->executeJs(sprintf('jQuery(document).xpath("%s").css(%s);', addslashes($locator), $this->cssStyle));
} else {
$this->debug('[Highlight Selector] ' . Locator::humanReadableString($locator));
$this->webDriverModule->executeJs(sprintf('jQuery("%s").css(%s);', addslashes($locator), $this->cssStyle));
}
}
} catch(Exception $e) {
$this->debug(sprintf("[Highlight Exception] %s \n%s", $e->getMessage(), $e->getTraceAsString()));
}
}

Expand Down

0 comments on commit d5625d4

Please sign in to comment.