{% autoescape 'js' %}
(function (xpath) {
  function getElement(xpath) {
    var polterAgent = window.__poltergeist;
    var ids = polterAgent.find("xpath", xpath, document);
    var polterNode = polterAgent.get(ids[0]);
    return polterNode.element;
  }

  var node = getElement(xpath);
  if(typeof node.selected == "undefined"){
    return null;
  }
  return node.selected;
}('{{xpath}}'));
{% endautoescape %}
