Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove all show_* methods. Use element collection methods with #each …

…instead. For example browser.links.each {|link| puts link.href}.
  • Loading branch information...
commit 701a44aeaa4bd4e03634da88104278da318cef3a 1 parent 47325e7
@jarmo jarmo authored
View
28 lib/watir-classic/container.rb
@@ -68,34 +68,6 @@ def __ole_inner_elements
return document.body.all
end
- # This method shows the available objects on the current page.
- # This is usually only used for debugging or writing new test scripts.
- # This is a nice feature to help find out what HTML objects are on a page
- # when developing a test case using Watir.
- def show_all_objects
- puts "-----------Objects in page -------------"
- doc = document
- s = ""
- props = ["name", "id", "value", "alt", "src"]
- doc.all.each do |n|
- begin
- s += n.invoke("type").to_s.ljust(16)
- rescue
- next
- end
- props.each do |prop|
- begin
- p = n.invoke(prop)
- s += " " + "#{prop}=#{p}".to_s.ljust(18)
- rescue
- # this object probably doesnt have this property
- end
- end
- s += "\n"
- end
- puts s
- end
-
# Locator Methods
#
# Not for external use, but cannot set to private due to usages in Element
View
147 lib/watir-classic/ie-class.rb
@@ -579,153 +579,6 @@ def disable_checker(checker)
@error_checkers.delete(checker)
end
- #
- # Show me state
- #
-
- # Show all forms displays all the forms that are on a web page.
- def show_forms
- if all_forms = self.forms
- count = all_forms.length
- puts "There are #{count} forms"
- all_forms.each do |form|
- puts "Form name: #{form.name}"
- puts " id: #{form.id}"
- puts " method: #{form.method}"
- puts " action: #{form.action}"
- end
- else
- puts "No forms"
- end
- end
-
- # this method shows all the images availble in the document
- def show_images
- doc = document
- index = 1
- doc.images.each do |l|
- puts "image: name: #{l.name}"
- puts " id: #{l.invoke("id")}"
- puts " src: #{l.src}"
- puts " index: #{index}"
- index += 1
- end
- end
-
- # this method shows all the links availble in the document
- def show_links
- props = ["name", "id", "href"]
- print_sizes = [12, 12, 60]
- doc = document
- index = 0
- text_size = 60
- # draw the table header
- s = "index".ljust(6)
- props.each_with_index do |p, i|
- s += p.ljust(print_sizes[i])
- end
- s += "text/src".ljust(text_size)
- s += "\n"
-
- # now get the details of the links
- doc.links.each do |n|
- index += 1
- s = s + index.to_s.ljust(6)
- props.each_with_index do |prop, i|
- printsize = print_sizes[i]
- begin
- p = n.invoke(prop)
- temp_var = "#{p}".to_s.ljust(printsize)
- rescue
- # this object probably doesnt have this property
- temp_var = "".to_s.ljust(printsize)
- end
- s += temp_var
- end
- s += n.innerText
- if n.getElementsByTagName("IMG").length > 0
- s += " / " + n.getElementsByTagName("IMG").item(0).src
- end
- s += "\n"
- end
- puts s
- end
-
- # this method shows the name, id etc of the object that is currently active - ie the element that has focus
- # its mostly used in irb when creating a script
- def show_active
- s = ""
-
- current = document.activeElement
- begin
- s += current.invoke("type").to_s.ljust(16)
- rescue
- end
- props = ["name", "id", "value", "alt", "src", "innerText", "href"]
- props.each do |prop|
- begin
- p = current.invoke(prop)
- s += " " + "#{prop}=#{p}".to_s.ljust(18)
- rescue
- #this object probably doesnt have this property
- end
- end
- s += "\n"
- end
-
- # this method shows all the divs availble in the document
- def show_divs
- divs = document.getElementsByTagName("DIV")
- puts "Found #{divs.length} div tags"
- index = 1
- divs.each do |d|
- puts "#{index} id=#{d.invoke('id')} class=#{d.invoke("className")}"
- index += 1
- end
- end
-
- # this method is used to show all the tables that are available
- def show_tables
- tables = document.getElementsByTagName("TABLE")
- puts "Found #{tables.length} tables"
- index = 1
- tables.each do |d|
- puts "#{index} id=#{d.invoke('id')} rows=#{d.rows.length} columns=#{begin d.rows["0"].cells.length; rescue; end}"
- index += 1
- end
- end
-
- def show_pres
- pres = document.getElementsByTagName("PRE")
- puts "Found #{ pres.length } pre tags"
- index = 1
- pres.each do |d|
- puts "#{index} id=#{d.invoke('id')} class=#{d.invoke("className")}"
- index+=1
- end
- end
-
- # this method shows all the spans availble in the document
- def show_spans
- spans = document.getElementsByTagName("SPAN")
- puts "Found #{spans.length} span tags"
- index = 1
- spans.each do |d|
- puts "#{index} id=#{d.invoke('id')} class=#{d.invoke("className")}"
- index += 1
- end
- end
-
- def show_labels
- labels = document.getElementsByTagName("LABEL")
- puts "Found #{labels.length} label tags"
- index = 1
- labels.each do |d|
- puts "#{index} text=#{d.invoke('innerText')} class=#{d.invoke("className")} for=#{d.invoke("htmlFor")}"
- index += 1
- end
- end
-
# Gives focus to the frame
def focus
active_element = document.activeElement
View
1  lib/watir-classic/ie.rb
@@ -3,6 +3,7 @@
require 'watir-classic/close_all'
require 'watir-classic/ie-process'
require 'watir-classic/screenshot'
+require 'yajl'
# these switches need to be deleted from ARGV to enable the Test::Unit
# functionality that grabs
View
22 lib/watir-classic/page-container.rb
@@ -47,7 +47,6 @@ def execute_script(source)
result = document.getElementById(wrapper).innerHTML
end
- require 'yajl'
Yajl::Parser.parse(result) rescue nil
end
@@ -71,27 +70,6 @@ def set_container container
@page_container = self
end
- # This method is used to display the available html frames that Internet Explorer currently has loaded.
- # This method is usually only used for debugging test scripts.
- def show_frames
- if allFrames = document.frames
- count = allFrames.length
- puts "there are #{count} frames"
- for i in 0..count-1 do
- begin
- fname = allFrames.item(i).name.to_s
- puts "frame index: #{i + 1} name: #{fname}"
- rescue => e
- if e.to_s.match(/Access is denied/)
- puts "frame index: #{i + 1} Access Denied, see http://wiki.openqa.org/display/WTR/FAQ#access-denied"
- end
- end
- end
- else
- puts "no frames"
- end
- end
-
# Search the current page for specified text or regexp.
# Returns the index if the specified text was found.
# Returns matchdata object if the specified regexp was found.
Please sign in to comment.
Something went wrong with that request. Please try again.