Class: Selenium::WebDriver::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/arachni/selenium/webdriver/element.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/arachni/selenium/webdriver/element.rb', line 31

def attributes
    @bridge.execute_script(
        %Q[
            var s = [];
            var attrs = arguments[0].attributes;
            for( var l = 0; l < attrs.length; ++l ) {
                s.push( attrs[l].name );
            }
            return s;
        ],
        self
    )
end

#eventsObject



24
25
26
27
28
29
# File 'lib/arachni/selenium/webdriver/element.rb', line 24

def events
    (@bridge.execute_script( 'return arguments[0]._arachni_events;', self ) || []).
        map { |event, fn| [event.to_sym, fn] } |
        (::Arachni::Browser::Javascript.events.flatten.map(&:to_s) & attributes).
            map { |event| [event.to_sym, attribute( event )] }
end

#htmlObject



5
6
7
# File 'lib/arachni/selenium/webdriver/element.rb', line 5

def html
    @bridge.execute_script( 'return arguments[0].outerHTML', self )
end

#opening_tagObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/arachni/selenium/webdriver/element.rb', line 9

def opening_tag
    @bridge.execute_script(
        %Q[
            var s = '<' + arguments[0].tagName.toLowerCase();
            var attrs = arguments[0].attributes;
            for( var l = 0; l < attrs.length; ++l ) {
                s += ' ' + attrs[l].name + '="' + attrs[l].value.replace( '"', '\"' ) + '"';
            }
            s += '>'
            return s;
        ],
        self
    )
end