Source
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
use Facebook\WebDriver\WebDriverBy;
use Facebook\WebDriver\Remote\RemoteWebElement;
use Facebook\WebDriver\Exception\StaleElementReferenceException;
/**
* Base class for web page elements.
*/
abstract class CBaseElement extends RemoteWebElement {
/**
* Option that allows to disable auto reload of staled elements.
*
* @var boolead
*/
protected $reload_staled = true;
/**
* Method called when element is stalled.
* This method should be overridden to provide logic of reloading stalled elements.
*/
public abstract function reload();
/**
* Execute element action in a stale safe context.
*
* @param string $method method to be executed
* @param array $params method execution params
*
* @return mixed
*/
private function executeStaleSafe($method, $params = []) {
try {
return call_user_func_array(['parent', $method], $params);
}
catch (StaleElementReferenceException $exception) {
if (!$this->reload_staled) {
throw $exception;
}
$this->reload();
}
// Workaraund for communication errors present on Jenkins
catch (\Facebook\WebDriver\Exception\WebDriverException $exception) {