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

Adding jQuery Selector Support #30

Open
agrublev opened this issue Nov 18, 2012 · 0 comments
Open

Adding jQuery Selector Support #30

agrublev opened this issue Nov 18, 2012 · 0 comments

Comments

@agrublev
Copy link

Using jQuery's amazing Selectors (well sizzles):

I spent some time getting this to work and it turned out to be much simpler than I thought so I thought i'd share.

So here is the snippet I came up which can be placed under the current get_element():

/**
 * Use jQuery
 * @param $selector - jQuery selection string - ex: "h3.awesome"
 * @param $advanced - using advanced jQuery travesing techniques - ex: ".find(".awesome")"
 * @return WebDriver_WebElement
 */
// See http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element
public function get_jq_element($selector,$advanced = "") {
    $response = $this->execute_js_sync('return $("'.$selector.'")'.$advanced.'.get(0);');
    return new WebDriver_WebElement($this, $response["ELEMENT"], $selector);
}
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

1 participant