-
Notifications
You must be signed in to change notification settings - Fork 0
/
testMacWin.rb
83 lines (71 loc) · 1.8 KB
/
testMacWin.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
70
71
72
73
74
75
76
77
78
79
80
require 'rspec/expectations'
require 'selenium-webdriver'
include RSpec::Matchers
require './LogReporter'
def setupHelper(session_id)
@logger = LogReporter.new(session_id)
end
def setupMac(browser_name)
# @driver = Selenium::WebDriver.for browser_name
@driver = Selenium::WebDriver.for(
:remote,
:url=> 'http://localhost:4444/wd/hub',
:desired_capabilities=> browser_name)
setupHelper(@driver.session_id)
rescue Exception => e
puts e.message
puts "Could not start driver"
exit 1
end
def setupWin(browser_name)
@driver = Selenium::WebDriver.for(
:remote,
:url=> 'http://localhost:4444/wd/hub',
:desired_capabilities=> browser_name)
setupHelper(@driver.session_id)
rescue Exception => e
puts e.message
puts "Could not start driver #{@browser_name}"
exit 1
end
def teardown
puts "in teardown"
@driver.quit
end
MACBROWSERS = [:firefox, :chrome]
WINBROWSERS = [:firefox, :chrome, :ie]
def run
MACBROWSERS.each do |macbrowser|
puts macbrowser
setupMac(macbrowser)
puts "Session id is #{@driver.session_id}"
yield
teardown
end
WINBROWSERS.each do |winbrowser|
puts winbrowser
setupWin(winbrowser)
yield
teardown
end
end
run do
@driver.get "http://the-internet.herokuapp.com"
puts @driver.capabilities.browser_name
puts @driver.capabilities.platform
puts @logger.latest
@[email protected]_name
begin
if @browser_name == "internet explorer"
puts ("#{@browser_name} inside if statement")
expect(@driver.title).to eql("The Internet")
else
puts ("#{@browser_name} inside else statement")
expect(@driver.title).to eql("The Internet")
end
rescue Exception => e
puts e.message
#puts "Could not start driver #{@browser_name}"
#exit 1
end
end