-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsharecare_search_profile.rb
71 lines (46 loc) · 1.83 KB
/
sharecare_search_profile.rb
1
2
3
4
5
6
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require "selenium-webdriver"
require "har"
require "fileutils"
profile = Selenium::WebDriver::Firefox::Profile.new
profile.add_extension File.expand_path("../extensions/firebug-1.6.2.xpi", __FILE__)
profile['extensions.firebug.currentVersion'] = "1.6.2" # avoid 'first run' tab
profile["extensions.firebug.previousPlacement"] = 1
profile["extensions.firebug.onByDefault"] = true
profile["extensions.firebug.defaultPanelName"] = "net"
profile["extensions.firebug.net.enableSites"] = true
profile["extensions.firebug.allPagesActivation"] = "on"
profile.add_extension File.expand_path("../extensions/fireStarter-0.1.a5.xpi", __FILE__)
profile.add_extension File.expand_path("../extensions/netExport-0.8b8.xpi", __FILE__)
profile["extensions.firebug.netexport.alwaysEnableAutoExport"] = true
profile["extensions.firebug.netexport.autoExportToFile"] = true
profile["extensions.firebug.netexport.defaultLogDir"] = File.expand_path("../output_dir/", __FILE__)
driver = Selenium::WebDriver.for :firefox , :profile => profile
driver.get "http://www.sharecare.com"
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
ask_text = wait.until {
element = driver.find_element(:name => "query")
element if element.displayed?
}
ask_text.clear
ask_text.send_keys "chickenpox"
ask_button = driver.find_element(:class => "ask")
ask_button.click
sleep(10)
driver.quit
=begin
look in output_dir for new .har file
put/read contents of .har
move .har to archive folder
=end
p HAR::Archive.from_file(File.expand_path("../output_dir/www.sharecare.com+2011-06-20+17-31-08.har", __FILE__)).to_json
#puts Dir.entries("../output_dir/").grep(/\.har/)
#p File.expand_path("../output_dir/#{Dir.glob("*.har")}", __FILE__)
=begin
counter = 1
file = File.new("../output_dir/*.har", "r")
while (line = file.gets)
puts "#{counter}: #{line}"
counter = counter + 1
end
file.close
=end