-
Notifications
You must be signed in to change notification settings - Fork 4
Basic Usage
Aldrin Martoq edited this page May 4, 2016
·
12 revisions
Just require 'webdrone'
and call Webdrone.create
with a timeout:
parameter (required). Using the returned object you can open a URL, fill forms, click HTML elements, etc. We use a0
as the name of this object, it is short and sweet.
For closing the browser, call a0.quit
.
require 'webdrone'
a0 = Webdrone.create timeout: 5
a0.open.url 'http://www.google.com/'
a0.form.set 'q', 'Servicios A0 SpA'
a0.form.submit
a0.wait.time 1
a0.clic.on 'Maps'
a0.wait.time 5
a0.quit
If you want to make sure the browser is closed no matter what, pass a block of code to Webdrone.create
.
Webdrone.create timeout: 5 do |a0|
a0.open.url 'http://www.google.com/'
a0.form.set 'q', 'Servicios A0 SpA'
a0.form.submit
a0.wait.time 1
a0.clic.on 'Maps'
a0.wait.time 5
end
Using a block on create
has the advantage that any exception will be handled by Webdrone. See Error Handling.
By default, Webdrone uses Firefox. To change the browser, use the browser:
parameter:
a0 = Webdrone.create timeout: 10, browser: :chrome
Current tested browsers are :firefox
, :safari
, :ie
and :chrome
; running on OS X, Linux and Windows.