You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.9 KiB
82 lines
2.9 KiB
<?php
|
|
|
|
|
|
namespace Prometeo\CommandsBundle\Commands;
|
|
|
|
use Symfony\Component\Console\Command\Command as ContainerAwareCommand;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
|
|
|
class Selenium2Katalon extends ContainerAwareCommand
|
|
{
|
|
private $em;
|
|
public function __construct(ContainerInterface $container)
|
|
{
|
|
parent::__construct();
|
|
$this->em = $container->get('doctrine')->getManager();
|
|
}
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function configure(): void
|
|
{
|
|
$this->setName('prometeo:test:selenium2katalon');
|
|
$this->addArgument(
|
|
'seleniumfile',
|
|
InputArgument::REQUIRED,
|
|
'Selenium File in SIDE format'
|
|
)
|
|
;
|
|
$this->addArgument(
|
|
'katalonfile',
|
|
InputArgument::OPTIONAL,
|
|
'Katalon File in HTML format'
|
|
);
|
|
}
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function execute(InputInterface $input, OutputInterface $output): void
|
|
{
|
|
$seleniumfile=$input->getArgument('seleniumfile');
|
|
if ($input->getArgument('prefix')) {
|
|
$katalonfile=$input->getArgument('katalonfile');
|
|
}else{
|
|
$katalonfile=$seleniumfile.'.html';
|
|
}
|
|
$selenium=file_get_contents($seleniumfile);
|
|
$seleniumobj=json_decode($selenium,true);
|
|
$header="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
|
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
|
|
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
|
|
<head>
|
|
<meta content=\"text/html; charset=UTF-8\" http-equiv=\"content-type\" />
|
|
<title>".$seleniumobj['name']."</title>
|
|
</head>";
|
|
$body='<body>';
|
|
foreach($seleniumobj['tests'] as $test){
|
|
$body.="<table cellpadding=\"1\" cellspacing=\"1\" border=\"1\">
|
|
<thead>
|
|
<tr><td rowspan=\"1\" colspan=\"3\">".$test['name']."</td></tr>
|
|
</thead>
|
|
<tbody>";
|
|
foreach($test['commands'] as $command){
|
|
$body.="<tr><td>".$command['command']."</td><td>".$command['target']."<datalist>";
|
|
foreach($command['targets'] as $target){
|
|
$body.="<option>".$target[0]."</option>";
|
|
}
|
|
$body.='</datalist></td><td>'.$command['value']."</td></tr>";
|
|
}
|
|
$body.="</tbody></table>";
|
|
}
|
|
$body='</body></html>';
|
|
file_put_contents($katalonfile,$header.$body);
|
|
echo "Conversion finalizada";
|
|
}
|
|
|
|
}
|