* Adjust result output logic.
This commit is contained in:
@@ -13,7 +13,7 @@ include dirname(__FILE__) . '/product.class.php';
|
||||
$tester = new product();
|
||||
|
||||
$product = array();
|
||||
r($tester->createProduct($product)) && p('text:nameTip') && e('『产品名称』不能为空。'); // 判断名称是否必输
|
||||
r($tester->createProduct($product)) && p('text:nameTip;value:PO,code') && e('『产品名称』不能为空。'); // 判断名称是否必输
|
||||
die;
|
||||
$product['name'] = array('setValue' => '产品' . time());
|
||||
$result = $tester->createProductTest($product);
|
||||
|
||||
+42
-13
@@ -104,6 +104,45 @@ function zget($var, $key, $valueWhenNone = false, $valueWhenExists = false)
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get webdriver page attr.
|
||||
*
|
||||
* @param string $arrKey
|
||||
* @param array $keys
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
function getPageAttr($arrKey, $keys)
|
||||
{
|
||||
global $result;
|
||||
$value = new stdclass();
|
||||
$page = $result->get('page');
|
||||
$method = 'get' . ucfirst($arrKey);
|
||||
foreach($keys as $key)
|
||||
{
|
||||
if(in_array($arrKey, array('text', 'attr', 'value')))
|
||||
{
|
||||
if(strpos($key, '-') === false)
|
||||
{
|
||||
$value->$key = $page->{$key}->$method();
|
||||
}
|
||||
else
|
||||
{
|
||||
$pos = strpos($key, '-');
|
||||
$element = substr($key, 0, $pos);
|
||||
$attr = substr($key, $pos + 1);
|
||||
$value->$key = $page->{$element}->$method($attr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$value->$key = $page->$method();
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values
|
||||
*
|
||||
@@ -124,23 +163,13 @@ function getValues($value, $keys, $delimiter)
|
||||
|
||||
$index = $arrKey;
|
||||
}
|
||||
$keys = explode($delimiter, $keys);
|
||||
|
||||
$keys = explode($delimiter, $keys);
|
||||
if($index != -1)
|
||||
{
|
||||
if(in_array($arrKey, array('text', 'attr', 'url', 'title')))
|
||||
if(in_array($arrKey, array('text', 'attr', 'url', 'title', 'value')))
|
||||
{
|
||||
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();
|
||||
}
|
||||
$value = getPageAttr($arrKey, $keys);
|
||||
}
|
||||
elseif(is_array($value))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user