Class: BlackStack::PampaBrowser
- Inherits:
-
Watir::Browser
- Object
- Watir::Browser
- BlackStack::PampaBrowser
- Defined in:
- lib/browserfactory.rb
Instance Attribute Summary collapse
-
#agent_name ⇒ Object
Returns the value of attribute agent_name.
-
#lnuser ⇒ Object
Returns the value of attribute lnuser.
-
#profile_name ⇒ Object
Returns the value of attribute profile_name.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
Instance Method Summary collapse
- #back ⇒ Object
- #execute_script(script, *args) ⇒ Object
- #forward ⇒ Object
- #goto(url) ⇒ Object
- #inspect ⇒ Object
- #notify(method) ⇒ Object
- #push_screenshot(filename = nil) ⇒ Object
- #refresh ⇒ Object
- #reset! ⇒ Object
- #screenshot ⇒ Object
-
#text ⇒ Object
def send_keys(*args) self.notify(“send_keys”) super end.
- #title ⇒ Object
- #url ⇒ Object
- #wait(timeout = 5) ⇒ Object
Instance Attribute Details
#agent_name ⇒ Object
Returns the value of attribute agent_name.
8 9 10 |
# File 'lib/browserfactory.rb', line 8 def agent_name @agent_name end |
#lnuser ⇒ Object
Returns the value of attribute lnuser.
8 9 10 |
# File 'lib/browserfactory.rb', line 8 def lnuser @lnuser end |
#profile_name ⇒ Object
Returns the value of attribute profile_name.
8 9 10 |
# File 'lib/browserfactory.rb', line 8 def profile_name @profile_name end |
#proxy ⇒ Object
Returns the value of attribute proxy.
8 9 10 |
# File 'lib/browserfactory.rb', line 8 def proxy @proxy end |
Instance Method Details
#back ⇒ Object
64 65 66 67 68 |
# File 'lib/browserfactory.rb', line 64 def back self.notify("back") super self.push_screenshot end |
#execute_script(script, *args) ⇒ Object
76 77 78 79 80 |
# File 'lib/browserfactory.rb', line 76 def execute_script(script, *args) self.notify("execute_script") super self.push_screenshot end |
#forward ⇒ Object
70 71 72 73 74 |
# File 'lib/browserfactory.rb', line 70 def forward self.notify("forward") super self.push_screenshot end |
#goto(url) ⇒ Object
82 83 84 85 86 |
# File 'lib/browserfactory.rb', line 82 def goto(url) self.notify("goto") super self.push_screenshot end |
#inspect ⇒ Object
104 105 106 107 |
# File 'lib/browserfactory.rb', line 104 def inspect self.notify("inspect") super end |
#notify(method) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/browserfactory.rb', line 10 def notify(method) url = "#{BlackStack::Pampa::api_protocol}://#{PROCESS.ws_url}:#{PROCESS.ws_port}/api1.3/pampa/browser/notify.json" res = BlackStack::Netting::call_post(url, { :api_key => BlackStack::Pampa::api_key, :filename => $0, :method => method, :worker_name => PROCESS.fullWorkerName, :id_proxy => self.proxy.nil? ? nil : self.proxy.id, :id_lnuser => self.lnuser.nil? ? nil : self.lnuser.id, :worker_assigned_process => PROCESS.worker.assigned_process, :profile_name => self.profile_name, :agent_name => self.agent_name, }) parsed = JSON.parse(res.body) if parsed['status'] != "success" raise "Error Tracing BrowserActivity: #{parsed['status']}" end end |
#push_screenshot(filename = nil) ⇒ Object
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 |
# File 'lib/browserfactory.rb', line 29 def push_screenshot(filename=nil) filename = "#{PROCESS.fullWorkerName}.png" if filename.nil? BrowserFactory::screenshot(filename) image = MiniMagick::Image.open(filename) w = (image[:width].to_f * 0.25).to_i h = (image[:height].to_f * 0.25).to_i image.resize "#{w.to_s}x#{h.to_s}" image.format "png" image.write filename url = "#{BlackStack::Pampa::api_protocol}://#{PROCESS.ws_url}:#{PROCESS.ws_port}/api1.3/pampa/browser/screenshot.json" res = RestClient::Request.execute( :api_key => BlackStack::Pampa::api_key, :verify_ssl => false, :url => url, :method => :post, :headers => { :accept => 'application/json', :params => { :api_key => BlackStack::Pampa.api_key, :filename => filename, }, }, :payload => { :file => File.new(filename, "r"), :multipart => false, } ) parsed = JSON.parse(res.body) if parsed['status'] != "success" raise "Error Uploading Screenshot: #{parsed['status']}" end end |
#refresh ⇒ Object
98 99 100 101 102 |
# File 'lib/browserfactory.rb', line 98 def refresh self.notify("refresh") super self.push_screenshot end |
#reset! ⇒ Object
93 94 95 96 |
# File 'lib/browserfactory.rb', line 93 def reset! self.notify("reset!") super end |
#screenshot ⇒ Object
88 89 90 91 |
# File 'lib/browserfactory.rb', line 88 def screenshot self.notify("screenshot") super end |
#text ⇒ Object
def send_keys(*args)
self.notify("send_keys")
super
end
116 117 118 119 |
# File 'lib/browserfactory.rb', line 116 def text self.notify("text") super end |
#title ⇒ Object
121 122 123 124 |
# File 'lib/browserfactory.rb', line 121 def title self.notify("title") super end |
#url ⇒ Object
126 127 128 129 |
# File 'lib/browserfactory.rb', line 126 def url self.notify("url") super end |
#wait(timeout = 5) ⇒ Object
131 132 133 134 |
# File 'lib/browserfactory.rb', line 131 def wait(timeout = 5) self.notify("wait") super end |