Class: Ext::Selenium
- Inherits:
-
Selenium::Client::Driver
- Object
- Selenium::Client::Driver
- Ext::Selenium
- Defined in:
- lib/selenium-extjs/Selenium.rb
Instance Method Summary collapse
- #find_ext(args) ⇒ Object
- #get_cmp(id, parent = nil) ⇒ Object
-
#initialize(args) ⇒ Selenium
constructor
A new instance of Selenium.
- #wait_for_component_visible(id) ⇒ Object
Constructor Details
#initialize(args) ⇒ Selenium
3 4 5 |
# File 'lib/selenium-extjs/Selenium.rb', line 3 def initialize(args) super(args) end |
Instance Method Details
#find_ext(args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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 |
# File 'lib/selenium-extjs/Selenium.rb', line 7 def find_ext(args) if args.kind_of? Hash exp = "" parent = nil xtype = nil filters = [] args.each do |k,v| filters << case k # use para botões. when :icon_cls " (el.iconCls?(el.iconCls.indexOfind_extf('#{v}') != -1):false) " when :title " (el.title?(el.title == '#{v}'):false) " when :title_has " (el.title?(el.title.indexOf('#{v}') != -1):false) " when :wait nil when :text " (el.getText?(el.getText() == '#{v}'):false) " when :xtype xtype = v Ext::condition_xtype(v) when :xparent if v.is_a? Ext::Component parent = v " el.findParentBy(function(o) { return o.getId() == '#{v.getId()}' }) " else " el.findParentBy(function(o) { return o.getXType() == '#{v}' }) " end else Ext::condition_default(k, v) end end exp = filters.compact().join(" && ") p "window.Ext.ComponentMgr.all.find(function(el){ return #{exp} }).getId()" # wait for element. if args.has_key?(:wait) && args[:wait] wait_for_condition("null != window.Ext.ComponentMgr.all.find(function(el){ return (#{exp}); })") end id = get_eval("window.Ext.ComponentMgr.all.find(function(el){ return (#{exp}); }).getId()") return get_cmp(id, parent) end end |
#get_cmp(id, parent = nil) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/selenium-extjs/Selenium.rb', line 59 def get_cmp(id, parent=nil) xtypes = get_eval("window.Ext.getCmp('#{id}').getXTypes()") selected_xtype = nil for xtype in xtypes.split("/").reverse() do if Ext::ComponentMgr::registered? xtype.to_sym selected_xtype = xtype.to_sym break end end return Ext::ComponentMgr::create selected_xtype, id, parent, self end |
#wait_for_component_visible(id) ⇒ Object
55 56 57 |
# File 'lib/selenium-extjs/Selenium.rb', line 55 def wait_for_component_visible(id) wait_for_condition("window.Ext.getCmp('#{id}').isVisible()") end |