Class: Ext::Component
- Inherits:
-
Object
- Object
- Ext::Component
- Defined in:
- lib/selenium-extjs/component/Component.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #getId ⇒ Object
- #highlight ⇒ Object
- #init_component ⇒ Object
-
#initialize(id, parent = nil, selenium = nil) ⇒ Component
constructor
A new instance of Component.
-
#method_missing(method_name, *args, &block) ⇒ Object
algumas ideias…
-
#node ⇒ Object
common tag element for this element.
-
#selector ⇒ Object
xpath for this element.
- #wait_for_ajax ⇒ Object
Constructor Details
#initialize(id, parent = nil, selenium = nil) ⇒ Component
Returns a new instance of Component.
9 10 11 12 13 14 |
# File 'lib/selenium-extjs/component/Component.rb', line 9 def initialize(id, parent = nil, selenium = nil) @id = id @parent = parent @selenium = selenium init_component() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
algumas ideias… obj.items_component_array -> serializar o retorno em uma lista tratar obj.store
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/selenium-extjs/component/Component.rb', line 23 def method_missing(method_name, *args, &block) # cmp = "window.Ext.getCmp('#{@id}')" # TODO: unit for validate this :p # registered? # is_registered # isRegistered() if method_name.to_s.end_with? "=" return nil end # convert method name to ext model. method_name = Ext::extfy(method_name.to_s) # build js arguments list arguments = Ext::arguments(args) # move to selenium. cmd = Ext::build_remote_call(@id, method_name, arguments) p cmd ret = @selenium.get_eval(cmd) if ret.start_with? "JSON:" ret = JSON ret.split(":", 2)[1] end if ret == "true" || ret == "false" ret = (ret =="true") end if ret.is_a? Hash if ret.has_key? "cmpid" p "---->" p ret return @selenium.get_cmp(ret["cmpid"], nil) else return ret end else return ret end end |
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
6 7 8 |
# File 'lib/selenium-extjs/component/Component.rb', line 6 def parent @parent end |
Instance Method Details
#getId ⇒ Object
90 91 92 |
# File 'lib/selenium-extjs/component/Component.rb', line 90 def getId() return @id end |
#highlight ⇒ Object
94 95 96 |
# File 'lib/selenium-extjs/component/Component.rb', line 94 def highlight @selenium.highlight(selector()) end |
#init_component ⇒ Object
16 17 |
# File 'lib/selenium-extjs/component/Component.rb', line 16 def init_component() end |
#node ⇒ Object
common tag element for this element
75 76 77 |
# File 'lib/selenium-extjs/component/Component.rb', line 75 def node return "//div[@id='#{@id}']" end |
#selector ⇒ Object
xpath for this element.
80 81 82 83 84 85 86 87 88 |
# File 'lib/selenium-extjs/component/Component.rb', line 80 def selector p @parent sel = "" if @parent && @parent.getId() sel += @parent.selector() end sel += node() return sel end |
#wait_for_ajax ⇒ Object
70 71 72 |
# File 'lib/selenium-extjs/component/Component.rb', line 70 def wait_for_ajax @selenium.wait_for_condition("window.Ext.Ajax.isLoading() == false") end |