-
Notifications
You must be signed in to change notification settings - Fork 2
/
simple_test_script.rb
46 lines (34 loc) · 1.46 KB
/
simple_test_script.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
require 'eyes_selenium'
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless') if ENV['CI'] == 'true'
runner = Applitools::ClassicRunner.new
eyes = Applitools::Selenium::Eyes.new(runner: runner)
web_driver = Selenium::WebDriver.for :chrome, options: options
eyes.batch = Applitools::BatchInfo.new("Demo Batch - Selenium Ruby - Classic")
eyes.configure do |conf|
conf.app_name = 'Demo App - Selenium Ruby - Classic'
conf.test_name = 'Smoke Test - Selenium Ruby - Classic'
conf.viewport_size = Applitools::RectangleSize.new(800, 600)
end
begin
# Call Open on eyes to initialize a test session
driver = eyes.open(driver: web_driver)
# Navigate to the url we want to test
driver.get('https://demo.applitools.com')
# Note to see visual bugs, run the test using the above URL for the 1st run.
# but then change the above URL to https://demo.applitools.com/index_v2.html (for the 2nd run)
# check the login page
eyes.check(name: 'Login window', target: Applitools::Selenium::Target.window.fully)
# Click the 'Log In' button
driver.find_element(:id, 'log-in').click
# Check the app page
eyes.check(name: 'App window', target: Applitools::Selenium::Target.window.fully)
eyes.close
ensure
# Close the browser
driver.quit
# If the test was aborted before eyes.close / eyes.close_async was called, ends the test as aborted.
eyes.abort_if_not_closed
# Get and print all test results
puts runner.get_all_test_results
end