Skip to content

Adding jQuery Selector Support #30

@agrublev

Description

@agrublev

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions