* Adjust ui test case check rule.

This commit is contained in:
caoyanyi
2024-04-22 14:25:49 +08:00
committed by liyang
parent b840a6c946
commit ea7e1afaee
5 changed files with 39 additions and 60 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ include dirname(__FILE__) . '/product.class.php';
$tester = new product();
$product = array();
r($tester->createProduct($product)) && p('nameTip:text') && e('『产品名称』不能为空。'); // 判断名称是否必输
r($tester->createProduct($product)) && p('text:nameTip') && e('『产品名称』不能为空。'); // 判断名称是否必输
die;
$product['name'] = array('setValue' => '产品' . time());
$result = $tester->createProductTest($product);
+5 -6
View File
@@ -11,12 +11,13 @@ class product
*/
public function createProduct($formData)
{
global $lang, $results;
$productPage = new productPage();
loadModel('user')->login();
$productPage->go('product', 'mainNav');
global $lang, $result;
$productPage = new productPage();
$result->setPage($productPage);
$productPage->go('product', 'mainNav');
$productPage->btn($lang->product->addBtn)->click();
$productPage->wait(1)->getErrors("appIframe-product");
@@ -33,8 +34,6 @@ class product
$productPage->btn($lang->product->saveBtn)->click();
$productPage->wait(1);
$results->setPage($productPage);
return $productPage;
}
}
+1 -1
View File
@@ -5,7 +5,7 @@ class page
public $xpathName;
public $doms;
public $xpath;
public $timeout = 5;
public $timeout = 30;
public function __construct()
{
+15 -15
View File
@@ -66,7 +66,7 @@ class result
$this->saveReport($message);
}
public function setPage($page)
public function setPage(&$page)
{
$this->pageObject = $page;
}
@@ -77,25 +77,25 @@ class result
* @access public
* @return void
*/
public function get()
public function get($param = '')
{
$results = array();
$results['caseTitle'] = $this->caseTitle;
$results['caseCode'] = $this->caseCode;
$results['reportFile'] = $this->reportFile;
$results['reportWebRoot'] = $this->reportURL;
$results['errors'] = $this->errors;
$results['page'] = $this->pageObject;
if(!empty($results['errors']))
if(!empty($this->errors))
{
foreach($results['errors'] as $error) echo str_replace("\n", '', $error) . PHP_EOL;
foreach($this->errors as $error) echo str_replace("\n", '', $error) . PHP_EOL;
return array();
return $param ? '' : array();
}
return $results;
$result = array();
$result['caseTitle'] = $this->caseTitle;
$result['caseCode'] = $this->caseCode;
$result['reportFile'] = $this->reportFile;
$result['reportWebRoot'] = $this->reportURL;
$result['errors'] = $this->errors;
$result['page'] = $this->pageObject;
return $param ? zget($result, $param, '') : $result;
}
}
$results = new result();
$result = new result();
+17 -37
View File
@@ -55,7 +55,7 @@ function r($result)
*/
function p($keys = '', $delimiter = ',')
{
global $_result, $results;
global $_result;
if(empty($_result)) return print(implode("\n", array_fill(0, substr_count($keys, $delimiter) + 1, 0)) . "\n");
@@ -64,14 +64,6 @@ function p($keys = '', $delimiter = ',')
/* Print $_result. */
if($keys === '' && is_array($_result)) return print_r($_result) . "\n";
if($keys === '' || !is_array($_result) && !is_object($_result)) return print((string) $_result . "\n");
if(in_array(explode(':', $keys)[1], array('text', 'attr', 'url', 'title')))
{
list($elementName, $action) = explode(':', $keys);
if($action == 'text') $results->get()['page']->$elementName->getText();
if($action == 'url') $results->get()['page']->getUrl();
if($action == 'title') $results->get()['page']->getTitle();
}
$parts = explode(';', $keys);
foreach($parts as $part)
@@ -123,7 +115,6 @@ function zget($var, $key, $valueWhenNone = false, $valueWhenExists = false)
*/
function getValues($value, $keys, $delimiter)
{
$object = '';
$index = -1;
$pos = strpos($keys, ':');
if($pos)
@@ -131,38 +122,27 @@ function getValues($value, $keys, $delimiter)
$arrKey = substr($keys, 0, $pos);
$keys = substr($keys, $pos + 1);
$pos = strpos($arrKey, '[');
if($pos)
{
$object = substr($arrKey, 0, $pos);
$index = trim(substr($arrKey, $pos + 1), ']');
}
else
{
$index = $arrKey;
}
$index = $arrKey;
}
$keys = explode($delimiter, $keys);
if($object !== '')
{
if(is_array($value))
{
$value = $value[$object];
}
else if(is_object($value))
{
$value = $value->$object;
}
else
{
return print("Error: No object name '$object'.\n");
}
}
if($index != -1)
{
if(is_array($value))
if(in_array($arrKey, array('text', 'attr', 'url', 'title')))
{
global $result;
$page = $result->get('page');
$method = 'get' . ucfirst($arrKey);
if($arrKey == 'text')
{
if(count($keys) == 1) $value = $page->{$keys[0]}->$method();
}
else
{
$value = $page->$method();
}
}
elseif(is_array($value))
{
if(!isset($value[$index])) return print("Error: Cannot get index $index.\n");
$value = $value[$index];