Exemplo n.º 1
0
 /**
  * Returns FQSEN-name of current method (without class name)
  *
  * @return string FQSEN of current method
  *
  * @see CodeGenerator::fqsenForMethod()
  */
 function getNameFQSEN()
 {
     return CodeGenerator::fqsenForMethod($this->name);
 }
// add to common method list (method and its derivative methods)
$methods[] = $mSelect;
$methods[] = $generator->createNewMethodWithName($mSelect, 'selectAndWait');
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// ---- attachFile
$mAttachFile = Method::createNew();
$mAttachFile->name = 'attachFile';
$mAttachFile->type = Method::determineTypeByName($mAttachFile->name);
$mAttachFile->subtype = Method::determineSubtypeByName($mAttachFile->name);
$mAttachFile->description = 'Sets a file input (upload) field to the file listed in fileLocator.';
// first argument
$argument = Argument::createNew();
$argument->name = 'fieldLocator';
$argument->type = Argument::DEFAULT_TYPE;
$argument->description = 'an element locator (see ' . CodeGenerator::linkToProperty('doc_Element_Locators', '', 'Element Locators') . ')';
$mAttachFile->addArgument($argument);
// second argument
$argument = Argument::createNew();
$argument->name = 'fileLocator';
$argument->type = Argument::DEFAULT_TYPE;
$argument->description = <<<TEXT
    a URL pointing to the specified file. Before the file can be set in the input field (fieldLocator),
    Selenium RC may need to transfer the file to the local machine before attaching the file in a web page form.
    This is common in selenium grid configurations where the RC server driving the browser is not the same machine
    that started the test. Supported Browsers: Firefox ("*chrome") only.
TEXT;
$mAttachFile->addArgument($argument);
// return value
$mAttachFile->returnValue = ReturnValue::createNew();
$mAttachFile->returnValue->type = ReturnValue::TYPE_VOID;
 /**
  * Prepares {@link Method::description} for phpDoc: replaces some words etc.
  *
  * @param string $methodDescription description of method
  *
  * @return string
  */
 private function _prepareMethodDescriptionForPhpDoc($methodDescription)
 {
     // direct replaces
     $phpDocDescription = strtr($methodDescription, ['@see #doSelect' => 'See ' . CodeGenerator::linkToMethod('select'), '<code>' => '[<b>', '</code>' => '</b>]']);
     return $phpDocDescription;
 }
use phpdocSeleniumGenerator\Helper;
use phpdocSeleniumGenerator\code_generator\CodeGenerator;
/**
 * @var models\Method[]|array $manualMethodsDescription Array of models, indexed by method name
 * @var models\Method[]|array $methodsByBaseName        Array of models, indexed by method name
 * @var models\Method[]       $methodsGroup
 */
// HTML documentation (local file can be changed to http://release.seleniumhq.org/selenium-core/1.0.1/reference.html)
define('SELENIUM_DOC_REFERENCE', 'source-doc/selenium-core-reference-1.0.1.html');
// Load manual description of some methods
$manualMethodsDescription = (require_once 'source-doc/manual_methods_description.php');
// Parsing of official documentation
$parser = new Parser(file_get_contents(SELENIUM_DOC_REFERENCE));
// Search description for available selenium commands (methods of phpunit-selenium-driver)
$driver = new phpunitSeleniumDriver();
$generator = new CodeGenerator();
$seleniumCommands = $driver->getAvailableSeleniumCommands();
$methodsByBaseName = [];
$notFounded = [];
foreach ($seleniumCommands as $methodFullName => $returnType) {
    // Create model of available method
    $method = models\Method::createNew();
    $method->name = $methodFullName;
    $method->type = models\Method::determineTypeByName($methodFullName);
    $method->subtype = models\Method::determineSubtypeByName($methodFullName);
    $method->returnValue = models\ReturnValue::createNew();
    $method->returnValue->type = $returnType;
    // Search of description in manual/parsed docs
    $documentedMethod = null;
    if (array_key_exists($methodFullName, $manualMethodsDescription)) {
        $documentedMethod = $manualMethodsDescription[$methodFullName];