SlideShare a Scribd company logo
The Agent                                                        Accessing page elements                                                      Forms
                                                              # The current page                                                    # Submitting a form without a button:
 require 'rubygems'                                                                                                                 form.submit
                                                              agent.page
 require 'mechanize'
                                                              # The HTML page content                                               # Submitting a form with the default button
 agent = WWW::Mechanize.new                                   page.body                                                             form.click_button()

 # disable keep_alive, when running into                      # forms, links, frames                                                # Submitting a form with a specific button
 # problems with session timeouts or getting an               page.forms, page.links, frames                                        form.click_button(form.button_with(:name => 'OK')
 # EOFError
                                                              # Selecting by criteria follows the pattern:                          # Form elements
 agent.keep_alive = false                                                                                                           form.fields, form.buttons, form.file_uploads, form.radio_buttons,
                                                              # page.element(s)_with(:criteria => value)
                                                              # The plural form (.elements) returns an                              form.checkboxes
 # Setting user agent:                                        # array, the singular form (.element) the
 agent.user_agent = 'Friendly Mechanize Script"               # first matching element or nil. Criteria                             # Form elements can be selected just like page elements
                                                              # is an attribute symbol and value may be                             # form.element(s)_with(:criteria => value)
 # Using one of the predefined user agents:                   # a string or a regular expression. If no                             # e.g.:
 # 'Mechanize', 'Mac Mozilla', 'Linux Mozilla'.               # criteria attributr is given, :name will                             form.field_with(:name => 'password')
                                                              # be used. e.g.:                                                      form.field_with('password')
 # 'Windows IE 6', 'iPhone', 'Linux Konqueror',
                                                              page.form_with(:name => 'formName')                                   form.checkboxes(:value => /view_.*/)
 # 'Windows IE 7', 'Mac FireFox', 'Mac Safari',
                                                              page.form_with('formName')
 # 'Windows Mozilla'                                                                                                                # Field values can also be selected directly by their name
                                                              page.links_with(:text => /[0-9]*/
 agent.user_agent_alias = 'Mac Safari'                                                                                              form.password = 'secret'

 # To verify server certificates:                                                                                                   # Setting field values
 # (A collection of certificates is available                                                                                       # field       : .value = 'something'
 # here: http://curl.haxx.se/ca/ )                                                                                                  # checkbox    : .(un)check / .checked = true|false
                                                                                                                                    # radio_button: .(un)check / .checked = true|false
 agent.ca_file = 'cacert.pem'
                                                                                                                                    # file_upload : .file_name = '/tmp/upload.dat'


                                                                            Ruby / Mechanize
                                                                                                                                    # e.g.:
 # Don't follow HTTP redirects                                                                                                      form.field_with('foo').value = 'something'
 agent.redirect_ok = false                                                                                                          form.checkbox_with(:value => 'blue').uncheck
                                                                                        http://mechanize.rubyforge.org/mechanize/   form.radio_buttons[3].check
 # Follow refresh in meta tags
 agent.follow_meta_refresh = true                                                               Nokogiri                            # Select lists / drop down fields:
                                                                                                                                    form.field_with('color').option[2].select
                                                                                                   http://nokogiri.org/             form.field_with('color').options.find{|o| o.value == 'red'}.select
 # Enable logging
                                                                                                                                    form.field_with('color').select_none
 require 'logger'                                                                                                                   form.field_with('color').select_all
 agent.log = Logger.new('mechanize.log')


                                                                                                                                                    Parsing the page content
                                                                                                                                    # Selecting elements from the documents DOM
                                                                                     Hello Mechanize!                               nodes = agent.page.search('expression')
                                                                                                                                    nodes = agent.page / 'expression'
                                                             require 'rubygems'
                                                             require 'mechanize'
           Navigation/History                                                                                                       # Selecting the first matching element or nil
                                                             agent = WWW::Mechanize.new                                             node = agent.page.at('expression')
# load a page                                                agent.get('http://rubyforge.org/')
agent.get('http://the.internet.net')                                                                                                # 'expression' might be an XPath or CSS selector
                                                             agent.page.forms.first.words = 'mechanize'                             nodes = agent.page.search('//h2/a[@class="title"]')
# Go back to the last page:                                  agent.page.forms.first.click_button                                    nodes = agent.page.search('.h2 a.title')
agent.back
                                                             agent.page.link_with(:text => /WWW::Mechanize/).click
                                                             agent.page.link_with(:text => 'Files').click
                                                                                                                                    # navigating the document tree:
# Follow a link by its text
agent.link_with(:text => 'click me').click                                                                                          node.parent
                                                             links = agent.page / 'strong/a'                                        node.children
# Backup history, execute block and                          version = links.find do |link|
# restore history                                              link['href'] =~ /shownotes.*release_id/                              # node content and attributes
agent.transact do                                            end.text                                                               node.text
  ...                                                                                                                               node.inner_html
end                                                          puts "Hello Mechanize #{version}!"
                                                                                                                                    node.attributes['width']

                                                                                                                                    # found nodes, can be searched the same way
                                                                                                                                    rows = agent.page / 'table/tr'
Version 2010-01-30                           Creative Commons License                                                               value = rows[0].at('td[@class="value"]').text
(c) 2010 Tobias Grimm                        http://creativecommons.org/licenses/by/3.0

More Related Content

What's hot

Rails <form> Chronicle
Rails <form> ChronicleRails <form> Chronicle
Rails <form> Chronicle
Kyosuke MOROHASHI
 
Curso Symfony - Clase 2
Curso Symfony - Clase 2Curso Symfony - Clase 2
Curso Symfony - Clase 2
Javier Eguiluz
 
Drupal8 simplepage v2
Drupal8 simplepage v2Drupal8 simplepage v2
Drupal8 simplepage v2
Samuel Solís Fuentes
 
Routing in Drupal 8
Routing in Drupal 8Routing in Drupal 8
Routing in Drupal 8
kgoel1
 
Routing in Drupal 8
Routing in Drupal 8Routing in Drupal 8
Routing in Drupal 8
kgoel1
 
Rails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiRails MVC by Sergiy Koshovyi
Rails MVC by Sergiy Koshovyi
Pivorak MeetUp
 
Everything you always wanted to know about forms* *but were afraid to ask
Everything you always wanted to know about forms* *but were afraid to askEverything you always wanted to know about forms* *but were afraid to ask
Everything you always wanted to know about forms* *but were afraid to ask
Andrea Giuliano
 
Taming forms with React
Taming forms with ReactTaming forms with React
Taming forms with React
GreeceJS
 
Django Templates
Django TemplatesDjango Templates
Django Templates
Willy Liu
 
Django Bogotá. CBV
Django Bogotá. CBVDjango Bogotá. CBV
Django Bogotá. CBV
ctrl-alt-delete
 
Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2
Sumy PHP User Grpoup
 
Ajax nested form and ajax upload in rails
Ajax nested form and ajax upload in railsAjax nested form and ajax upload in rails
Ajax nested form and ajax upload in rails
Tse-Ching Ho
 
Leveraging Symfony2 Forms
Leveraging Symfony2 FormsLeveraging Symfony2 Forms
Leveraging Symfony2 Forms
Bernhard Schussek
 
Send, pass, get variables with php, form, html & java script code
Send, pass, get variables with php, form, html & java script codeSend, pass, get variables with php, form, html & java script code
Send, pass, get variables with php, form, html & java script code
Noushadur Shoukhin
 
Ch9 .Best Practices for Class-Based Views
Ch9 .Best Practices  for  Class-Based ViewsCh9 .Best Practices  for  Class-Based Views
Ch9 .Best Practices for Class-Based Views
Willy Liu
 
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...Atlassian
 
Template rendering in rails
Template rendering in rails Template rendering in rails
Template rendering in rails
Hung Wu Lo
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
Kyle Cearley
 
Building Web Service Clients with ActiveModel
Building Web Service Clients with ActiveModelBuilding Web Service Clients with ActiveModel
Building Web Service Clients with ActiveModelpauldix
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2
Sumy PHP User Grpoup
 

What's hot (20)

Rails <form> Chronicle
Rails <form> ChronicleRails <form> Chronicle
Rails <form> Chronicle
 
Curso Symfony - Clase 2
Curso Symfony - Clase 2Curso Symfony - Clase 2
Curso Symfony - Clase 2
 
Drupal8 simplepage v2
Drupal8 simplepage v2Drupal8 simplepage v2
Drupal8 simplepage v2
 
Routing in Drupal 8
Routing in Drupal 8Routing in Drupal 8
Routing in Drupal 8
 
Routing in Drupal 8
Routing in Drupal 8Routing in Drupal 8
Routing in Drupal 8
 
Rails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiRails MVC by Sergiy Koshovyi
Rails MVC by Sergiy Koshovyi
 
Everything you always wanted to know about forms* *but were afraid to ask
Everything you always wanted to know about forms* *but were afraid to askEverything you always wanted to know about forms* *but were afraid to ask
Everything you always wanted to know about forms* *but were afraid to ask
 
Taming forms with React
Taming forms with ReactTaming forms with React
Taming forms with React
 
Django Templates
Django TemplatesDjango Templates
Django Templates
 
Django Bogotá. CBV
Django Bogotá. CBVDjango Bogotá. CBV
Django Bogotá. CBV
 
Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2
 
Ajax nested form and ajax upload in rails
Ajax nested form and ajax upload in railsAjax nested form and ajax upload in rails
Ajax nested form and ajax upload in rails
 
Leveraging Symfony2 Forms
Leveraging Symfony2 FormsLeveraging Symfony2 Forms
Leveraging Symfony2 Forms
 
Send, pass, get variables with php, form, html & java script code
Send, pass, get variables with php, form, html & java script codeSend, pass, get variables with php, form, html & java script code
Send, pass, get variables with php, form, html & java script code
 
Ch9 .Best Practices for Class-Based Views
Ch9 .Best Practices  for  Class-Based ViewsCh9 .Best Practices  for  Class-Based Views
Ch9 .Best Practices for Class-Based Views
 
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
 
Template rendering in rails
Template rendering in rails Template rendering in rails
Template rendering in rails
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
Building Web Service Clients with ActiveModel
Building Web Service Clients with ActiveModelBuilding Web Service Clients with ActiveModel
Building Web Service Clients with ActiveModel
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2
 

Viewers also liked

Khóa học đánh dj chuyên nghiệp
Khóa học đánh dj chuyên nghiệpKhóa học đánh dj chuyên nghiệp
Khóa học đánh dj chuyên nghiệp
Góc chia sẻ
 
Diet clinic noida health care
Diet clinic noida health careDiet clinic noida health care
Diet clinic noida health care
pkdietclinic
 
Entrenamiento del dia jueves 21 06-2012
Entrenamiento del dia jueves 21 06-2012Entrenamiento del dia jueves 21 06-2012
Entrenamiento del dia jueves 21 06-2012Diego Rojas
 
saabab_cbrne_transportpackaging_2015_web
saabab_cbrne_transportpackaging_2015_websaabab_cbrne_transportpackaging_2015_web
saabab_cbrne_transportpackaging_2015_webPeter Richards
 

Viewers also liked (9)

Khóa học đánh dj chuyên nghiệp
Khóa học đánh dj chuyên nghiệpKhóa học đánh dj chuyên nghiệp
Khóa học đánh dj chuyên nghiệp
 
Curso tablet e lousa
Curso tablet e lousaCurso tablet e lousa
Curso tablet e lousa
 
Vinay Sharma Resume
Vinay Sharma ResumeVinay Sharma Resume
Vinay Sharma Resume
 
Official Resume
Official ResumeOfficial Resume
Official Resume
 
Ravindra_Resume
Ravindra_ResumeRavindra_Resume
Ravindra_Resume
 
Diet clinic noida health care
Diet clinic noida health careDiet clinic noida health care
Diet clinic noida health care
 
Entrenamiento del dia jueves 21 06-2012
Entrenamiento del dia jueves 21 06-2012Entrenamiento del dia jueves 21 06-2012
Entrenamiento del dia jueves 21 06-2012
 
saabab_cbrne_transportpackaging_2015_web
saabab_cbrne_transportpackaging_2015_websaabab_cbrne_transportpackaging_2015_web
saabab_cbrne_transportpackaging_2015_web
 
Mulut
MulutMulut
Mulut
 

Similar to SAVIA

Functional testing with capybara
Functional testing with capybaraFunctional testing with capybara
Functional testing with capybara
koffeinfrei
 
Capybara
CapybaraCapybara
Capybara
Flavian Missi
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
Viget Labs
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
Ben Scofield
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011
Arun Gupta
 
Ember.js for Big Profit
Ember.js for Big ProfitEmber.js for Big Profit
Ember.js for Big Profit
CodeCore
 
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...
Uniface
 
From Ruby to Node.js
From Ruby to Node.jsFrom Ruby to Node.js
From Ruby to Node.js
jubilem
 
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Arun Gupta
 
68837.ppt
68837.ppt68837.ppt
68837.ppt
BruceLee275640
 
Tony Vitabile .Net Portfolio
Tony Vitabile .Net PortfolioTony Vitabile .Net Portfolio
Tony Vitabile .Net Portfolio
vitabile
 
R Tanenbaum .Net Portfolio
R Tanenbaum .Net PortfolioR Tanenbaum .Net Portfolio
R Tanenbaum .Net Portfolio
Robert Tanenbaum
 
Web I - 04 - Forms
Web I - 04 - FormsWeb I - 04 - Forms
Web I - 04 - Forms
Randy Connolly
 
Sencha Touch - Introduction
Sencha Touch - IntroductionSencha Touch - Introduction
Sencha Touch - Introduction
ABC-GROEP.BE
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
Siarhei Barysiuk
 
Devise and Rails
Devise and RailsDevise and Rails
Devise and Rails
William Leeper
 

Similar to SAVIA (20)

Functional testing with capybara
Functional testing with capybaraFunctional testing with capybara
Functional testing with capybara
 
Capybara
CapybaraCapybara
Capybara
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011
 
Ember.js for Big Profit
Ember.js for Big ProfitEmber.js for Big Profit
Ember.js for Big Profit
 
The Rails Way
The Rails WayThe Rails Way
The Rails Way
 
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...
 
Cmsc 100 (web forms)
Cmsc 100 (web forms)Cmsc 100 (web forms)
Cmsc 100 (web forms)
 
From Ruby to Node.js
From Ruby to Node.jsFrom Ruby to Node.js
From Ruby to Node.js
 
Iktomi lightning talk
Iktomi lightning talkIktomi lightning talk
Iktomi lightning talk
 
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
 
68837.ppt
68837.ppt68837.ppt
68837.ppt
 
Tony Vitabile .Net Portfolio
Tony Vitabile .Net PortfolioTony Vitabile .Net Portfolio
Tony Vitabile .Net Portfolio
 
R Tanenbaum .Net Portfolio
R Tanenbaum .Net PortfolioR Tanenbaum .Net Portfolio
R Tanenbaum .Net Portfolio
 
Web I - 04 - Forms
Web I - 04 - FormsWeb I - 04 - Forms
Web I - 04 - Forms
 
Sencha Touch - Introduction
Sencha Touch - IntroductionSencha Touch - Introduction
Sencha Touch - Introduction
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
 
Devise and Rails
Devise and RailsDevise and Rails
Devise and Rails
 
Rhino Mocks
Rhino MocksRhino Mocks
Rhino Mocks
 

Recently uploaded

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 

Recently uploaded (20)

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 

SAVIA

  • 1. The Agent Accessing page elements Forms # The current page # Submitting a form without a button: require 'rubygems' form.submit agent.page require 'mechanize' # The HTML page content # Submitting a form with the default button agent = WWW::Mechanize.new page.body form.click_button() # disable keep_alive, when running into # forms, links, frames # Submitting a form with a specific button # problems with session timeouts or getting an page.forms, page.links, frames form.click_button(form.button_with(:name => 'OK') # EOFError # Selecting by criteria follows the pattern: # Form elements agent.keep_alive = false form.fields, form.buttons, form.file_uploads, form.radio_buttons, # page.element(s)_with(:criteria => value) # The plural form (.elements) returns an form.checkboxes # Setting user agent: # array, the singular form (.element) the agent.user_agent = 'Friendly Mechanize Script" # first matching element or nil. Criteria # Form elements can be selected just like page elements # is an attribute symbol and value may be # form.element(s)_with(:criteria => value) # Using one of the predefined user agents: # a string or a regular expression. If no # e.g.: # 'Mechanize', 'Mac Mozilla', 'Linux Mozilla'. # criteria attributr is given, :name will form.field_with(:name => 'password') # be used. e.g.: form.field_with('password') # 'Windows IE 6', 'iPhone', 'Linux Konqueror', page.form_with(:name => 'formName') form.checkboxes(:value => /view_.*/) # 'Windows IE 7', 'Mac FireFox', 'Mac Safari', page.form_with('formName') # 'Windows Mozilla' # Field values can also be selected directly by their name page.links_with(:text => /[0-9]*/ agent.user_agent_alias = 'Mac Safari' form.password = 'secret' # To verify server certificates: # Setting field values # (A collection of certificates is available # field : .value = 'something' # here: http://curl.haxx.se/ca/ ) # checkbox : .(un)check / .checked = true|false # radio_button: .(un)check / .checked = true|false agent.ca_file = 'cacert.pem' # file_upload : .file_name = '/tmp/upload.dat' Ruby / Mechanize # e.g.: # Don't follow HTTP redirects form.field_with('foo').value = 'something' agent.redirect_ok = false form.checkbox_with(:value => 'blue').uncheck http://mechanize.rubyforge.org/mechanize/ form.radio_buttons[3].check # Follow refresh in meta tags agent.follow_meta_refresh = true Nokogiri # Select lists / drop down fields: form.field_with('color').option[2].select http://nokogiri.org/ form.field_with('color').options.find{|o| o.value == 'red'}.select # Enable logging form.field_with('color').select_none require 'logger' form.field_with('color').select_all agent.log = Logger.new('mechanize.log') Parsing the page content # Selecting elements from the documents DOM Hello Mechanize! nodes = agent.page.search('expression') nodes = agent.page / 'expression' require 'rubygems' require 'mechanize' Navigation/History # Selecting the first matching element or nil agent = WWW::Mechanize.new node = agent.page.at('expression') # load a page agent.get('http://rubyforge.org/') agent.get('http://the.internet.net') # 'expression' might be an XPath or CSS selector agent.page.forms.first.words = 'mechanize' nodes = agent.page.search('//h2/a[@class="title"]') # Go back to the last page: agent.page.forms.first.click_button nodes = agent.page.search('.h2 a.title') agent.back agent.page.link_with(:text => /WWW::Mechanize/).click agent.page.link_with(:text => 'Files').click # navigating the document tree: # Follow a link by its text agent.link_with(:text => 'click me').click node.parent links = agent.page / 'strong/a' node.children # Backup history, execute block and version = links.find do |link| # restore history link['href'] =~ /shownotes.*release_id/ # node content and attributes agent.transact do end.text node.text ... node.inner_html end puts "Hello Mechanize #{version}!" node.attributes['width'] # found nodes, can be searched the same way rows = agent.page / 'table/tr' Version 2010-01-30 Creative Commons License value = rows[0].at('td[@class="value"]').text (c) 2010 Tobias Grimm http://creativecommons.org/licenses/by/3.0