Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about list of methods in comment block at top of WebDriver.php #23

Open
ghost opened this issue Oct 30, 2013 · 2 comments
Open

Comments

@ghost
Copy link

ghost commented Oct 30, 2013

Hi,

Just wondering about this,
You have a big list of methods here, in a big comment block, but the comment doesn't give an indication where these methods are implemented or how they can be used?
For example the string "findElementByCssSelector" doesn't exist in any other php files in the SeleniumClient dir besides in this comment block of WebDriver.php.
And they're all shown with the namespace SeleniumClient\WebElement, yet they work directly on the webdriver object, for example:
require "/path/to/SeleniumClient/WebDriver.php";
$driver = new SeleniumClient\WebDriver();
$el = $driver->findElementsByCssSelector($sel); #works
?

/**

  • @param string $selectorValue
  • @param string $selectorDefinition
  • @param bool $polling
  • @method \SeleniumClient\WebElement findElementByCssSelector($selectorValue, $polling=false)
  • @method \SeleniumClient\WebElement findElementById($selectorValue, $polling=false)
  • @method \SeleniumClient\WebElement findElementByJsSelector($selectorValue, $selectorDefinition='$', $polling=false)
  • @method \SeleniumClient\WebElement findElementByLinkText($selectorValue, $polling=false)
  • @method \SeleniumClient\WebElement findElementByName($selectorValue, $polling=false)
  • @method \SeleniumClient\WebElement findElementByPartialLinkText($selectorValue, $polling=false)
  • @method \SeleniumClient\WebElement findElementByTagName($selectorValue, $polling=false)
  • @method \SeleniumClient\WebElement findElementByXPath($selectorValue, $polling=false)
    *
  • @method \SeleniumClient\WebElement[] findElementsByCssSelector($selectorValue, $polling=false)
  • @method \SeleniumClient\WebElement[] findElementsById($selectorValue, $polling=false)
  • @method \SeleniumClient\WebElement[] findElementsByJsSelector($selectorValue, $selectorDefinition='$', $polling=false)
  • @method \SeleniumClient\WebElement[] findElementsByLinkText($selectorValue, $polling=false)
  • @method \SeleniumClient\WebElement[] findElementsByName($selectorValue, $polling=false)
  • @method \SeleniumClient\WebElement[] findElementsByPartialLinkText($selectorValue, $polling=false)
  • @method \SeleniumClient\WebElement[] findElementsByTagName($selectorValue, $polling=false)
  • @method \SeleniumClient\WebElement[] findElementsByXPath($selectorValue, $polling=false)
    */
@polosantiago
Copy link
Contributor

Hey @Lope, those methods are made available to a WebDriver object through the __call magic method. If there is a method called to a WebDriver and is not found, then this method catches the request and takes decision on what to do.

http://www.php.net/manual/en/language.oop5.overloading.php#object.call

I know this block of comments doesn't look right (at least in that place) we are removing it in upcoming changes.

Thanks for your feedback, is very valuable to get points of view outside our team.

@andrewmackrodt
Copy link
Contributor

Hi @Lope, I added these changes a few months ago part of pull request #13. These magic methods are designed to aid auto-completion for developers using an IDE whilst reducing the amount of namespace imports and typing required, e.g.

# with magic methods
$webElement = $driver->findElementById("nav");

# without magic methods (requires additional namespace import)
$webElement = $driver->findElement(By::id("nav"));

The namespace \SeleniumClient\WebElement indicates the return type of the magic method. PhpStorm, NetBeans, Zend Studio are amongst popular IDEs that should understand this format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants