Sha256: 3c4e24f1545ec11463e8df22e3bd055061b311676d2738316ed06d300fb392c7

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

// stolen from injectableSelenium.js in WebDriver

var browserbot = {

    triggerEvent : function(element, eventType, canBubble, controlKeyDown, altKeyDown, shiftKeyDown, metaKeyDown) {
        canBubble = (typeof(canBubble) == undefined) ? true : canBubble;
        if (element.fireEvent && element.ownerDocument && element.ownerDocument.createEventObject) { // IE
            var evt = this.createEventObject(element, controlKeyDown, altKeyDown, shiftKeyDown, metaKeyDown);
            element.fireEvent('on' + eventType, evt);
        } else {
            var evt = document.createEvent('HTMLEvents');

            try {
                evt.shiftKey = shiftKeyDown;
                evt.metaKey = metaKeyDown;
                evt.altKey = altKeyDown;
                evt.ctrlKey = controlKeyDown;
            } catch (e) {
                // Nothing sane to do
            }

            evt.initEvent(eventType, canBubble, true);
            element.dispatchEvent(evt);
        }
    },

    getVisibleText : function() {
        var selection = getSelection();
        var range = document.createRange();
        range.selectNodeContents(document.documentElement);
        selection.addRange(range);
        return selection.toString();
    },

    getOuterHTML : function(element) {
          if(element.outerHTML) {
            return element.outerHTML;
          } else if (typeof(XMLSerializer) != undefined) {
              return new XMLSerializer().serializeToString(element);
          } else {
              throw "can't get outerHTML in this browser";
          }
    }


};

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watir-webdriver-0.0.1.dev3 lib/watir-webdriver/browserbot.js
watir-webdriver-0.0.1.dev2 lib/watir-webdriver/browserbot.js