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
|
# File 'lib/learn_test/strategies/protractor.rb', line 21
def run
unless selenium_running?
stdin, stdout, stderr, wait_thr = Open3.popen3('webdriver-manager start')
@pid = wait_thr.pid
@server_started = false
while !@server_started && line = stderr.gets do
puts line
if line.include?('Selenium Server is up and running')
@server_started = true
stdin.close
stdout.close
stderr.close
end
end
end
Open3.popen3('protractor conf.js --resultJsonOutputFile .results.json') do |stdin, stdout, stderr, wait_thr|
while line = stdout.gets do
if line.include?('Error: Cannot find module')
@modules_missing = true
end
puts line
end
while stderr_line = stderr.gets do
puts stderr_line
end
if wait_thr.value.exitstatus != 0
if @modules_missing
die("You appear to be missing npm dependencies. Try running `npm install`\nIf the issue persists, check the package.json")
end
end
end
safe_kill(@pid)
safe_kill(@selenium_pid) if selenium_running?
end
|