FeatureContext.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. use Behat\Behat\Context\ClosuredContextInterface,
  3. Behat\Behat\Context\TranslatedContextInterface,
  4. Behat\Behat\Context\BehatContext,
  5. Behat\Behat\Exception\PendingException;
  6. use Behat\Gherkin\Node\PyStringNode,
  7. Behat\Gherkin\Node\TableNode;
  8. use Behat\MinkExtension\Context\MinkContext;
  9. //
  10. // Require 3rd-party libraries here:
  11. //
  12. // require_once 'PHPUnit/Autoload.php';
  13. // require_once 'PHPUnit/Framework/Assert/Functions.php';
  14. //
  15. /**
  16. * Features context.
  17. */
  18. class FeatureContext extends MinkContext
  19. {
  20. /**
  21. * Initializes context.
  22. * Every scenario gets its own context object.
  23. *
  24. * @param array $parameters context parameters (set them up through behat.yml)
  25. */
  26. public function __construct(array $parameters)
  27. {
  28. // Initialize your context here
  29. }
  30. /**
  31. * @Given /^I click on "([^"]*)"$/
  32. */
  33. public function iClickOn($arg1)
  34. {
  35. # $findName = $this->getSession()->getPage()->find("css", $arg1);
  36. # if (!$findName) {
  37. # throw new Exception($arg1 . " could not be found");
  38. # } else {
  39. # $findName->click();
  40. # }
  41. }
  42. /**
  43. * @Given /^there are clients:$/
  44. */
  45. public function thereAreClients(TableNode $table)
  46. {
  47. foreach ($table->getHash() as $row => $val) {
  48. echo $val['name'] . " - " . $val['Teléfono'] ."\n";
  49. //$element = $this->getSession()->getPage()->find('css','INPUT#s593ed56c26a8a_externalId');
  50. // $element = $this->getSession()->getPage()->find('xpath','//input[contains(@id, "externalId")]');
  51. $element = $this->getSession()->getPage()->find('id', "externalId");
  52. $this->fillField($element, $val['External Id']);
  53. $this->getSession()->wait(3000);
  54. $element2 = $this->getSession()->getPage()->find('xpath','//input[contains(@id, "name")]');
  55. $this->fillField($element2, $val['name']);
  56. #s593ffd8703a40_name
  57. # $element = $this->getSession()->getPage()->find('css','INPUT#s593ed56c26a8a_externalId');
  58. # $this->fillField($element, $val['Companía']);
  59. # $element = $this->getSession()->getPage()->find('css','INPUT#s593ed56c26a8a_externalId');
  60. # $this->fillField($element, $val['Comentario']);
  61. # $element = $this->getSession()->getPage()->find('css','INPUT#s593ed56c26a8a_externalId');
  62. # $this->fillField($element, $val['Email']);
  63. # $element = $this->getSession()->getPage()->find('css','INPUT#s593ed56c26a8a_externalId');
  64. # $this->fillField($element, $val['Teléfono']);
  65. }
  66. # $element = $this->getSession()->getPage()->find('css','INPUT#s593ed56c26a8a_externalId');
  67. # $this->fillField($element, "Hello World!");
  68. # $element->setValue('aa');
  69. # css=a[id$='_id_sufix'];
  70. }
  71. /**
  72. * @Given /^espero a que se cargue$/
  73. */
  74. public function esperoAQueSeCargue()
  75. {
  76. $this->getSession()->wait(5000);
  77. }
  78. /**
  79. * @Given /^relleno el campo "([^"]*)" con "([^"]*)"$/
  80. */
  81. public function rellenoElCampoCon($arg1, $arg2)
  82. {
  83. # $rem = ("[id*=$arg1]");
  84. # echo $rem;
  85. $dom = new DomDocument;
  86. //load the html into the object
  87. $dom->loadHTML($html);
  88. //discard white space
  89. $dom->preserveWhiteSpace = false;
  90. $input_tags = $dom->getElementsByTagName('input');
  91. echo $input_tags;
  92. # $element = getElementById("[id*=$arg1]");
  93. # $element = $page->findAll('id', $arg1);
  94. }
  95. //
  96. // Place your definition and hook methods here:
  97. //
  98. // /**
  99. // * @Given /^I have done something with "([^"]*)"$/
  100. // */
  101. // public function iHaveDoneSomethingWith($argument)
  102. // {
  103. // doSomethingWith($argument);
  104. // }
  105. //
  106. }