ElementInterface.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /*
  3. * This file is part of the Mink package.
  4. * (c) Konstantin Kudryashov <ever.zet@gmail.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. namespace Behat\Mink\Element;
  10. use Behat\Mink\Session;
  11. /**
  12. * Element interface.
  13. *
  14. * @author Konstantin Kudryashov <ever.zet@gmail.com>
  15. */
  16. interface ElementInterface
  17. {
  18. /**
  19. * Returns XPath for handled element.
  20. *
  21. * @return string
  22. */
  23. public function getXpath();
  24. /**
  25. * Returns element's session.
  26. *
  27. * @return Session
  28. *
  29. * @deprecated Accessing the session from the element is deprecated as of 1.6 and will be impossible in 2.0.
  30. */
  31. public function getSession();
  32. /**
  33. * Checks whether element with specified selector exists inside the current element.
  34. *
  35. * @param string $selector selector engine name
  36. * @param string|array $locator selector locator
  37. *
  38. * @return Boolean
  39. *
  40. * @see ElementInterface::findAll for the supported selectors
  41. */
  42. public function has($selector, $locator);
  43. /**
  44. * Checks if an element still exists in the DOM.
  45. *
  46. * @return bool
  47. */
  48. public function isValid();
  49. /**
  50. * Waits for an element(-s) to appear and returns it.
  51. *
  52. * @param int|float $timeout Maximal allowed waiting time in seconds.
  53. * @param callable $callback Callback, which result is both used as waiting condition and returned.
  54. * Will receive reference to `this element` as first argument.
  55. *
  56. * @return mixed
  57. *
  58. * @throws \InvalidArgumentException When invalid callback given.
  59. */
  60. public function waitFor($timeout, $callback);
  61. /**
  62. * Finds first element with specified selector inside the current element.
  63. *
  64. * @param string $selector selector engine name
  65. * @param string|array $locator selector locator
  66. *
  67. * @return NodeElement|null
  68. *
  69. * @see ElementInterface::findAll for the supported selectors
  70. */
  71. public function find($selector, $locator);
  72. /**
  73. * Finds all elements with specified selector inside the current element.
  74. *
  75. * Valid selector engines are named, xpath, css, named_partial and named_exact.
  76. *
  77. * 'named' is a pseudo selector engine which prefers an exact match but
  78. * will return a partial match if no exact match is found.
  79. * 'xpath' is a pseudo selector engine supported by SelectorsHandler.
  80. *
  81. * More selector engines can be registered in the SelectorsHandler.
  82. *
  83. * @param string $selector selector engine name
  84. * @param string|array $locator selector locator
  85. *
  86. * @return NodeElement[]
  87. *
  88. * @see NamedSelector for the locators supported by the named selectors
  89. */
  90. public function findAll($selector, $locator);
  91. /**
  92. * Returns element text (inside tag).
  93. *
  94. * @return string
  95. */
  96. public function getText();
  97. /**
  98. * Returns element inner html.
  99. *
  100. * @return string
  101. */
  102. public function getHtml();
  103. }