diff options
author | Natalja Romancaka <natalja.romancaka@zabbix.com> | 2022-08-02 10:40:00 +0300 |
---|---|---|
committer | Natalja Romancaka <natalja.romancaka@zabbix.com> | 2022-08-02 10:46:07 +0300 |
commit | 81f5b0d88b1d8b16d3db3b691508811989f515d4 (patch) | |
tree | 92c3b3ea871321418e82ba111383097038aca789 | |
parent | 43cdb79b0c8670633da059d6e7308de29e5e2c1e (diff) |
.......... [ZBXNEXT-686] fixed Selenium test, added START_MAP workaround to CElementQuery
-rw-r--r-- | frontends/php/tests/include/web/CElementQuery.php | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/frontends/php/tests/include/web/CElementQuery.php b/frontends/php/tests/include/web/CElementQuery.php index 3fd7fdf29a0..80c5e2a0679 100644 --- a/frontends/php/tests/include/web/CElementQuery.php +++ b/frontends/php/tests/include/web/CElementQuery.php @@ -53,6 +53,7 @@ require_once dirname(__FILE__).'/CastableTrait.php'; use Facebook\WebDriver\WebDriverBy; use Facebook\WebDriver\Exception\NoSuchElementException; +use Facebook\WebDriver\Exception\WebDriverException; /** * Element selection query. @@ -345,25 +346,35 @@ class CElementQuery implements IWaitable { $class = $this->class; $parent = ($this->context !== static::getDriver()) ? $this->context : null; - try { - if (!$this->reverse_order) { - $element = $this->context->findElement($this->by); + for ($i = 0; $i < 2; $i++) { + try { + if (!$this->reverse_order) { + $element = $this->context->findElement($this->by); + } + else { + $elements = $this->context->findElements($this->by); + if (!$elements) { + throw new NoSuchElementException(null); + } + + $element = end($elements); + } + + break; } - else { - $elements = $this->context->findElements($this->by); - if (!$elements) { - throw new NoSuchElementException(null); + catch (NoSuchElementException $exception) { + if (!$should_exist) { + return new CNullElement(array_merge($this->options, ['parent' => $parent, 'by' => $this->by])); } - $element = end($elements); + throw $exception; } - } - catch (NoSuchElementException $exception) { - if (!$should_exist) { - return new CNullElement(array_merge($this->options, ['parent' => $parent, 'by' => $this->by])); + // Workaround for communication errors present on Jenkins + catch (WebDriverException $exception) { + if (strpos($exception->getMessage(), 'START_MAP') === false) { + throw $exception; + } } - - throw $exception; } return call_user_func([$class, 'createInstance'], $element, array_merge($this->options, [ @@ -380,7 +391,18 @@ class CElementQuery implements IWaitable { public function all() { $class = $this->class; - $elements = $this->context->findElements($this->by); + try { + $elements = $this->context->findElements($this->by); + } + // Workaround for communication errors present on Jenkins + catch (WebDriverException $exception) { + if (strpos($exception->getMessage(), 'START_MAP') === false) { + throw $exception; + } + + $elements = $this->context->findElements($this->by); + } + if ($this->reverse_order) { $elements = array_reverse($elements); } |