Skip to content

Instantly share code, notes, and snippets.

@prakapenka
Created April 15, 2015 14:10
Show Gist options
  • Save prakapenka/4ba5610d857455fd9e36 to your computer and use it in GitHub Desktop.
Save prakapenka/4ba5610d857455fd9e36 to your computer and use it in GitHub Desktop.
function cbust($val,$arr_1)
{
$res = 1;
for ($i=1;$i<=count($arr_1); $i++)
{
if ($val&$res){$arr_check[$i]=true;}else{$arr_check[$i]=false;}
$res = $res << 1;
}
foreach ($arr_1 as $k => $v)
{
if ($arr_check[($k+1)]===true)
{
$flag = $this->isElementPresent($v);
if ($flag!==true){$this->fail("Element $v is not present to check!");}
$flag = $this->isChecked($v);
if ($flag === true){} //nothing to do, it already cheked!
else
{$this->click($v);
$flag = $this->isChecked($v); //is click make some action?
if ($flag!==true){$this->fail("Element $v can not be checked!");}
}
}
elseif ($arr_check[($k+1)]===false)
{
$flag = $this->isElementPresent($v);
if ($flag!==true){$this->fail("Element $v is not present to uncheck!");}
$flag = $this->isChecked($v);
if ($flag===true)
{$this->uncheck($v);
$flag = $this->isChecked($v); //is uncheck make some action?
if ($flag===true){$this->fail("Element $v can not be UNchecked!");}
}
else {} //nothing to do!
}
else
{
$this->fail('Oops, not true and not false...??'); //value of $arr_1 may be not set...
}
}
$status = 'ok'; //for some reasons... It's pleasure to hear that all ok!
return $status;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment