browserstack-webdriver 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES +791 -0
- data/README.md +31 -0
- data/build.desc +334 -0
- data/lib/selenium-client.rb +2 -0
- data/lib/selenium-webdriver.rb +1 -0
- data/lib/selenium/client.rb +37 -0
- data/lib/selenium/client/base.rb +132 -0
- data/lib/selenium/client/driver.rb +10 -0
- data/lib/selenium/client/errors.rb +9 -0
- data/lib/selenium/client/extensions.rb +118 -0
- data/lib/selenium/client/idiomatic.rb +488 -0
- data/lib/selenium/client/javascript_expression_builder.rb +116 -0
- data/lib/selenium/client/javascript_frameworks/jquery.rb +13 -0
- data/lib/selenium/client/javascript_frameworks/prototype.rb +13 -0
- data/lib/selenium/client/legacy_driver.rb +1720 -0
- data/lib/selenium/client/protocol.rb +104 -0
- data/lib/selenium/client/selenium_helper.rb +34 -0
- data/lib/selenium/rake/server_task.rb +157 -0
- data/lib/selenium/server.rb +248 -0
- data/lib/selenium/webdriver.rb +71 -0
- data/lib/selenium/webdriver/android.rb +9 -0
- data/lib/selenium/webdriver/android/bridge.rb +47 -0
- data/lib/selenium/webdriver/chrome.rb +26 -0
- data/lib/selenium/webdriver/chrome/bridge.rb +120 -0
- data/lib/selenium/webdriver/chrome/profile.rb +90 -0
- data/lib/selenium/webdriver/chrome/service.rb +75 -0
- data/lib/selenium/webdriver/common.rb +44 -0
- data/lib/selenium/webdriver/common/action_builder.rb +352 -0
- data/lib/selenium/webdriver/common/alert.rb +30 -0
- data/lib/selenium/webdriver/common/bridge_helper.rb +67 -0
- data/lib/selenium/webdriver/common/core_ext/base64.rb +9 -0
- data/lib/selenium/webdriver/common/core_ext/dir.rb +42 -0
- data/lib/selenium/webdriver/common/core_ext/string.rb +5 -0
- data/lib/selenium/webdriver/common/driver.rb +301 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_browser_connection.rb +17 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +39 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +25 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +13 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +22 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +19 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +22 -0
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +45 -0
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +43 -0
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +46 -0
- data/lib/selenium/webdriver/common/element.rb +293 -0
- data/lib/selenium/webdriver/common/error.rb +207 -0
- data/lib/selenium/webdriver/common/file_reaper.rb +47 -0
- data/lib/selenium/webdriver/common/html5/local_storage.rb +42 -0
- data/lib/selenium/webdriver/common/html5/location.rb +0 -0
- data/lib/selenium/webdriver/common/html5/session_storage.rb +44 -0
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +42 -0
- data/lib/selenium/webdriver/common/json_helper.rb +34 -0
- data/lib/selenium/webdriver/common/keyboard.rb +55 -0
- data/lib/selenium/webdriver/common/keys.rb +109 -0
- data/lib/selenium/webdriver/common/log_entry.rb +29 -0
- data/lib/selenium/webdriver/common/logs.rb +23 -0
- data/lib/selenium/webdriver/common/mouse.rb +72 -0
- data/lib/selenium/webdriver/common/navigation.rb +43 -0
- data/lib/selenium/webdriver/common/options.rb +136 -0
- data/lib/selenium/webdriver/common/platform.rb +218 -0
- data/lib/selenium/webdriver/common/port_prober.rb +42 -0
- data/lib/selenium/webdriver/common/profile_helper.rb +67 -0
- data/lib/selenium/webdriver/common/proxy.rb +149 -0
- data/lib/selenium/webdriver/common/search_context.rb +92 -0
- data/lib/selenium/webdriver/common/socket_poller.rb +105 -0
- data/lib/selenium/webdriver/common/target_locator.rb +81 -0
- data/lib/selenium/webdriver/common/timeouts.rb +38 -0
- data/lib/selenium/webdriver/common/touch_action_builder.rb +64 -0
- data/lib/selenium/webdriver/common/touch_screen.rb +105 -0
- data/lib/selenium/webdriver/common/wait.rb +63 -0
- data/lib/selenium/webdriver/common/window.rb +104 -0
- data/lib/selenium/webdriver/common/zipper.rb +82 -0
- data/lib/selenium/webdriver/firefox.rb +37 -0
- data/lib/selenium/webdriver/firefox/binary.rb +158 -0
- data/lib/selenium/webdriver/firefox/bridge.rb +70 -0
- data/lib/selenium/webdriver/firefox/extension.rb +52 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +106 -0
- data/lib/selenium/webdriver/firefox/profile.rb +263 -0
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +62 -0
- data/lib/selenium/webdriver/firefox/socket_lock.rb +61 -0
- data/lib/selenium/webdriver/firefox/util.rb +29 -0
- data/lib/selenium/webdriver/ie.rb +19 -0
- data/lib/selenium/webdriver/ie/bridge.rb +68 -0
- data/lib/selenium/webdriver/ie/server.rb +86 -0
- data/lib/selenium/webdriver/iphone.rb +9 -0
- data/lib/selenium/webdriver/iphone/bridge.rb +45 -0
- data/lib/selenium/webdriver/opera.rb +24 -0
- data/lib/selenium/webdriver/opera/bridge.rb +112 -0
- data/lib/selenium/webdriver/opera/service.rb +49 -0
- data/lib/selenium/webdriver/phantomjs.rb +22 -0
- data/lib/selenium/webdriver/phantomjs/bridge.rb +59 -0
- data/lib/selenium/webdriver/phantomjs/service.rb +90 -0
- data/lib/selenium/webdriver/remote.rb +22 -0
- data/lib/selenium/webdriver/remote/bridge.rb +644 -0
- data/lib/selenium/webdriver/remote/capabilities.rb +267 -0
- data/lib/selenium/webdriver/remote/commands.rb +193 -0
- data/lib/selenium/webdriver/remote/http/common.rb +74 -0
- data/lib/selenium/webdriver/remote/http/curb.rb +79 -0
- data/lib/selenium/webdriver/remote/http/default.rb +139 -0
- data/lib/selenium/webdriver/remote/http/persistent.rb +38 -0
- data/lib/selenium/webdriver/remote/response.rb +97 -0
- data/lib/selenium/webdriver/remote/server_error.rb +17 -0
- data/lib/selenium/webdriver/safari.rb +46 -0
- data/lib/selenium/webdriver/safari/bridge.rb +110 -0
- data/lib/selenium/webdriver/safari/browser.rb +20 -0
- data/lib/selenium/webdriver/safari/extension.rb +120 -0
- data/lib/selenium/webdriver/safari/server.rb +145 -0
- data/lib/selenium/webdriver/support.rb +5 -0
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +28 -0
- data/lib/selenium/webdriver/support/block_event_listener.rb +17 -0
- data/lib/selenium/webdriver/support/color.rb +110 -0
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +112 -0
- data/lib/selenium/webdriver/support/select.rb +293 -0
- data/ruby.iml +13 -0
- data/spec/integration/selenium/client/api/backward_compatible_api_spec.rb +22 -0
- data/spec/integration/selenium/client/api/browser_xpath_library_spec.rb +17 -0
- data/spec/integration/selenium/client/api/click_spec.rb +39 -0
- data/spec/integration/selenium/client/api/cookie_spec.rb +39 -0
- data/spec/integration/selenium/client/api/element_spec.rb +14 -0
- data/spec/integration/selenium/client/api/highlight_located_element_spec.rb +19 -0
- data/spec/integration/selenium/client/api/retrieve_last_remote_control_logs_spec.rb +33 -0
- data/spec/integration/selenium/client/api/screenshot_spec.rb +31 -0
- data/spec/integration/selenium/client/api/select_window_spec.rb +46 -0
- data/spec/integration/selenium/client/api/start_stop_spec.rb +9 -0
- data/spec/integration/selenium/client/api/wait_for_ajax_spec.rb +27 -0
- data/spec/integration/selenium/client/api/wait_for_element_spec.rb +56 -0
- data/spec/integration/selenium/client/api/wait_for_field_value_spec.rb +52 -0
- data/spec/integration/selenium/client/api/wait_for_text_spec.rb +98 -0
- data/spec/integration/selenium/client/api/webdriver_backed_spec.rb +21 -0
- data/spec/integration/selenium/client/sample-app/public/jquery-1.3.2.js +4376 -0
- data/spec/integration/selenium/client/sample-app/public/jquery.html +55 -0
- data/spec/integration/selenium/client/sample-app/public/prototype-1.6.0.3.js +4320 -0
- data/spec/integration/selenium/client/sample-app/public/prototype.html +59 -0
- data/spec/integration/selenium/client/sample-app/sample_app.rb +32 -0
- data/spec/integration/selenium/client/spec_helper.rb +139 -0
- data/spec/integration/selenium/webdriver/app_cache_spec.rb +47 -0
- data/spec/integration/selenium/webdriver/browser_connection_spec.rb +20 -0
- data/spec/integration/selenium/webdriver/chrome/driver_spec.rb +28 -0
- data/spec/integration/selenium/webdriver/chrome/profile_spec.rb +63 -0
- data/spec/integration/selenium/webdriver/driver_spec.rb +266 -0
- data/spec/integration/selenium/webdriver/element_spec.rb +191 -0
- data/spec/integration/selenium/webdriver/error_spec.rb +30 -0
- data/spec/integration/selenium/webdriver/firefox/driver_spec.rb +21 -0
- data/spec/integration/selenium/webdriver/firefox/profile_spec.rb +141 -0
- data/spec/integration/selenium/webdriver/keyboard_spec.rb +57 -0
- data/spec/integration/selenium/webdriver/location_spec.rb +29 -0
- data/spec/integration/selenium/webdriver/mouse_spec.rb +57 -0
- data/spec/integration/selenium/webdriver/navigation_spec.rb +46 -0
- data/spec/integration/selenium/webdriver/opera/driver_spec.rb +47 -0
- data/spec/integration/selenium/webdriver/options_spec.rb +77 -0
- data/spec/integration/selenium/webdriver/remote/driver_spec.rb +19 -0
- data/spec/integration/selenium/webdriver/remote/element_spec.rb +26 -0
- data/spec/integration/selenium/webdriver/spec_helper.rb +36 -0
- data/spec/integration/selenium/webdriver/spec_support.rb +12 -0
- data/spec/integration/selenium/webdriver/spec_support/guards.rb +110 -0
- data/spec/integration/selenium/webdriver/spec_support/helpers.rb +51 -0
- data/spec/integration/selenium/webdriver/spec_support/rack_server.rb +123 -0
- data/spec/integration/selenium/webdriver/spec_support/test_environment.rb +239 -0
- data/spec/integration/selenium/webdriver/sql_database_spec.rb +59 -0
- data/spec/integration/selenium/webdriver/storage_spec.rb +96 -0
- data/spec/integration/selenium/webdriver/target_locator_spec.rb +186 -0
- data/spec/integration/selenium/webdriver/timeout_spec.rb +69 -0
- data/spec/integration/selenium/webdriver/touch_spec.rb +176 -0
- data/spec/integration/selenium/webdriver/window_spec.rb +70 -0
- data/spec/integration/selenium/webdriver/zipper_spec.rb +66 -0
- data/spec/unit/selenium/client/base_spec.rb +239 -0
- data/spec/unit/selenium/client/extensions_spec.rb +174 -0
- data/spec/unit/selenium/client/idiomatic_spec.rb +500 -0
- data/spec/unit/selenium/client/javascript_expression_builder_spec.rb +79 -0
- data/spec/unit/selenium/client/javascript_frameworks/jquery_spec.rb +10 -0
- data/spec/unit/selenium/client/javascript_frameworks/prototype_spec.rb +10 -0
- data/spec/unit/selenium/client/protocol_spec.rb +124 -0
- data/spec/unit/selenium/client/selenium_helper_spec.rb +56 -0
- data/spec/unit/selenium/client/spec_helper.rb +24 -0
- data/spec/unit/selenium/rake/task_spec.rb +79 -0
- data/spec/unit/selenium/server_spec.rb +150 -0
- data/spec/unit/selenium/webdriver/action_builder_spec.rb +97 -0
- data/spec/unit/selenium/webdriver/android/bridge_spec.rb +43 -0
- data/spec/unit/selenium/webdriver/chrome/bridge_spec.rb +137 -0
- data/spec/unit/selenium/webdriver/chrome/profile_spec.rb +57 -0
- data/spec/unit/selenium/webdriver/chrome/service_spec.rb +44 -0
- data/spec/unit/selenium/webdriver/error_spec.rb +41 -0
- data/spec/unit/selenium/webdriver/firefox/bridge_spec.rb +47 -0
- data/spec/unit/selenium/webdriver/ie/bridge_spec.rb +91 -0
- data/spec/unit/selenium/webdriver/iphone/bridge_spec.rb +42 -0
- data/spec/unit/selenium/webdriver/log_entry_spec.rb +11 -0
- data/spec/unit/selenium/webdriver/opera/bridge_spec.rb +44 -0
- data/spec/unit/selenium/webdriver/phantomjs/bridge_spec.rb +55 -0
- data/spec/unit/selenium/webdriver/proxy_spec.rb +106 -0
- data/spec/unit/selenium/webdriver/remote/bridge_spec.rb +16 -0
- data/spec/unit/selenium/webdriver/remote/capabilities_spec.rb +115 -0
- data/spec/unit/selenium/webdriver/remote/http/common_spec.rb +24 -0
- data/spec/unit/selenium/webdriver/remote/http/default_spec.rb +124 -0
- data/spec/unit/selenium/webdriver/search_context_spec.rb +61 -0
- data/spec/unit/selenium/webdriver/socket_poller_spec.rb +68 -0
- data/spec/unit/selenium/webdriver/spec_helper.rb +27 -0
- data/spec/unit/selenium/webdriver/support/color_spec.rb +119 -0
- data/spec/unit/selenium/webdriver/support/event_firing_spec.rb +111 -0
- data/spec/unit/selenium/webdriver/support/select_spec.rb +290 -0
- data/spec/unit/selenium/webdriver/wait_spec.rb +49 -0
- metadata +370 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
module Selenium
|
4
|
+
module WebDriver
|
5
|
+
describe Mouse do
|
6
|
+
|
7
|
+
not_compliant_on :browser => [:android, :iphone, :safari] do
|
8
|
+
it "clicks an element" do
|
9
|
+
driver.navigate.to url_for("formPage.html")
|
10
|
+
driver.mouse.click driver.find_element(:id, "imageButton")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "can drag and drop" do
|
14
|
+
driver.navigate.to url_for("droppableItems.html")
|
15
|
+
|
16
|
+
draggable = long_wait.until {
|
17
|
+
driver.find_element(:id => "draggable")
|
18
|
+
}
|
19
|
+
|
20
|
+
droppable = driver.find_element(:id => "droppable")
|
21
|
+
|
22
|
+
driver.mouse.down draggable
|
23
|
+
driver.mouse.move_to droppable
|
24
|
+
driver.mouse.up droppable
|
25
|
+
|
26
|
+
text = droppable.find_element(:tag_name => "p").text
|
27
|
+
text.should == "Dropped!"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "double clicks an element" do
|
31
|
+
driver.navigate.to url_for("javascriptPage.html")
|
32
|
+
element = driver.find_element(:id, 'doubleClickField')
|
33
|
+
|
34
|
+
driver.mouse.double_click element
|
35
|
+
|
36
|
+
wait(5).until {
|
37
|
+
element.attribute(:value) == 'DoubleClicked'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
not_compliant_on :browser => :phantomjs do
|
42
|
+
it "context clicks an element" do
|
43
|
+
driver.navigate.to url_for("javascriptPage.html")
|
44
|
+
element = driver.find_element(:id, 'doubleClickField')
|
45
|
+
|
46
|
+
driver.mouse.context_click element
|
47
|
+
|
48
|
+
wait(5).until {
|
49
|
+
element.attribute(:value) == 'ContextClicked'
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
describe "Navigation" do
|
4
|
+
let(:wait) { Selenium::WebDriver::Wait.new :timeout => 10 }
|
5
|
+
|
6
|
+
not_compliant_on :browser => :safari do
|
7
|
+
it "should navigate back and forward" do
|
8
|
+
form_title = "We Leave From Here"
|
9
|
+
result_title = "We Arrive Here"
|
10
|
+
form_url = url_for "formPage.html"
|
11
|
+
result_url = url_for "resultPage.html"
|
12
|
+
|
13
|
+
driver.navigate.to form_url
|
14
|
+
driver.title.should == form_title
|
15
|
+
|
16
|
+
driver.find_element(:id, 'imageButton').submit
|
17
|
+
wait.until { driver.title != form_title }
|
18
|
+
|
19
|
+
driver.current_url.should include(result_url)
|
20
|
+
driver.title.should == result_title
|
21
|
+
|
22
|
+
driver.navigate.back
|
23
|
+
|
24
|
+
driver.current_url.should include(form_url)
|
25
|
+
driver.title.should == form_title
|
26
|
+
|
27
|
+
driver.navigate.forward
|
28
|
+
driver.current_url.should include(result_url)
|
29
|
+
driver.title.should == result_title
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should refresh the page" do
|
33
|
+
changed_title = "Changed"
|
34
|
+
|
35
|
+
driver.navigate.to url_for("javascriptPage.html")
|
36
|
+
driver.find_element(:link_text, "Change the page title!").click
|
37
|
+
driver.title.should == changed_title
|
38
|
+
|
39
|
+
driver.navigate.refresh
|
40
|
+
wait.until { driver.title != changed_title }
|
41
|
+
|
42
|
+
driver.title.should == "Testing Javascript"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module Opera
|
4
|
+
|
5
|
+
describe Driver do
|
6
|
+
|
7
|
+
before(:all) { GlobalTestEnv.quit_driver rescue nil }
|
8
|
+
|
9
|
+
it 'raises ArgumentError if sent an unknown capability as an argument' do
|
10
|
+
lambda {
|
11
|
+
Selenium::WebDriver.for :opera, :foo => 'bar'
|
12
|
+
}.should raise_error(ArgumentError)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'accepts an array of custom command-line arguments' do
|
16
|
+
begin
|
17
|
+
driver = Selenium::WebDriver.for :opera, :arguments => ['-geometry 800x600']
|
18
|
+
ensure
|
19
|
+
driver.quit if driver
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'raises ArgumentError if :arguments is not an Array' do
|
24
|
+
lambda {
|
25
|
+
Selenium::WebDriver.for :opera, :arguments => '-foo'
|
26
|
+
}.should raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'accepts a valid logging level' do
|
30
|
+
begin
|
31
|
+
driver = Selenium::WebDriver.for :opera, :logging_level => :config
|
32
|
+
# TODO(andreastt): Validate output to console
|
33
|
+
ensure
|
34
|
+
driver.quit if driver
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'raises ArgumentError if :logging_level uses an invalid logging level' do
|
39
|
+
lambda {
|
40
|
+
Selenium::WebDriver.for :opera, :logging_level => :hoobaflooba
|
41
|
+
}.should raise_error(ArgumentError)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
module Selenium
|
5
|
+
module WebDriver
|
6
|
+
describe Options do
|
7
|
+
|
8
|
+
describe 'logs' do
|
9
|
+
compliant_on :driver => [:firefox] do
|
10
|
+
it 'can fetch available log types' do
|
11
|
+
driver.manage.logs.available_types.should == [:browser, :driver]
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'can get the browser log' do
|
15
|
+
driver.navigate.to url_for("simpleTest.html")
|
16
|
+
|
17
|
+
entries = driver.manage.logs.get(:browser)
|
18
|
+
entries.should_not be_empty
|
19
|
+
entries.first.should be_kind_of(LogEntry)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'can get the driver log' do
|
23
|
+
driver.navigate.to url_for("simpleTest.html")
|
24
|
+
|
25
|
+
entries = driver.manage.logs.get(:driver)
|
26
|
+
entries.should_not be_empty
|
27
|
+
entries.first.should be_kind_of(LogEntry)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "cookie management" do
|
33
|
+
it "should get all" do
|
34
|
+
driver.navigate.to url_for("xhtmlTest.html")
|
35
|
+
driver.manage.add_cookie :name => "foo", :value => "bar"
|
36
|
+
|
37
|
+
cookies = driver.manage.all_cookies
|
38
|
+
|
39
|
+
cookies.should have(1).things
|
40
|
+
cookies.first[:name].should == "foo"
|
41
|
+
cookies.first[:value].should == "bar"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should delete one" do
|
45
|
+
driver.navigate.to url_for("xhtmlTest.html")
|
46
|
+
|
47
|
+
driver.manage.add_cookie :name => "foo", :value => "bar"
|
48
|
+
driver.manage.delete_cookie("foo")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should delete all" do
|
52
|
+
driver.navigate.to url_for("xhtmlTest.html")
|
53
|
+
|
54
|
+
driver.manage.add_cookie :name => "foo", :value => "bar"
|
55
|
+
driver.manage.delete_all_cookies
|
56
|
+
driver.manage.all_cookies.should be_empty
|
57
|
+
end
|
58
|
+
|
59
|
+
not_compliant_on :browser => [:ie, :android, :iphone, :safari] do
|
60
|
+
it "should use DateTime for expires" do
|
61
|
+
driver.navigate.to url_for("xhtmlTest.html")
|
62
|
+
|
63
|
+
expected = DateTime.new(2039)
|
64
|
+
driver.manage.add_cookie :name => "foo",
|
65
|
+
:value => "bar",
|
66
|
+
:expires => expected
|
67
|
+
|
68
|
+
actual = driver.manage.cookie_named("foo")[:expires]
|
69
|
+
actual.should be_kind_of(DateTime)
|
70
|
+
actual.should == expected
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module Remote
|
4
|
+
|
5
|
+
describe Driver do
|
6
|
+
it "should expose session_id" do
|
7
|
+
driver.session_id.should be_kind_of(String)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should expose remote status" do
|
11
|
+
driver.should be_kind_of(DriverExtensions::HasRemoteStatus)
|
12
|
+
driver.remote_status.should be_kind_of(Hash)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end # Remote
|
17
|
+
end # WebDriver
|
18
|
+
end # Selenium
|
19
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
describe Element do
|
4
|
+
before do
|
5
|
+
driver.file_detector = lambda { |str| __FILE__ }
|
6
|
+
end
|
7
|
+
|
8
|
+
after do
|
9
|
+
driver.file_detector = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
not_compliant_on :browser => :phantomjs do
|
13
|
+
it "uses the file detector" do
|
14
|
+
driver.navigate.to url_for("upload.html")
|
15
|
+
|
16
|
+
driver.find_element(:id => "upload").send_keys("random string")
|
17
|
+
driver.find_element(:id => "go").submit
|
18
|
+
|
19
|
+
driver.switch_to.frame("upload_target")
|
20
|
+
body = driver.find_element(:xpath => "//body")
|
21
|
+
body.text.should include("uses the set file detector")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end # WebDriver
|
26
|
+
end # Selenium
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'time'
|
3
|
+
require 'rspec'
|
4
|
+
require 'ci/reporter/rspec'
|
5
|
+
|
6
|
+
require 'selenium-webdriver'
|
7
|
+
require 'selenium/webdriver/spec_support'
|
8
|
+
|
9
|
+
include Selenium
|
10
|
+
|
11
|
+
GlobalTestEnv = WebDriver::SpecSupport::TestEnvironment.new
|
12
|
+
|
13
|
+
class Object
|
14
|
+
include WebDriver::SpecSupport::Guards
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec.configure do |c|
|
18
|
+
c.include(WebDriver::SpecSupport::Helpers)
|
19
|
+
c.before(:suite) do
|
20
|
+
if GlobalTestEnv.driver == :remote
|
21
|
+
GlobalTestEnv.remote_server.start
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
c.after(:suite) do
|
26
|
+
GlobalTestEnv.quit_driver
|
27
|
+
end
|
28
|
+
|
29
|
+
c.filter_run :focus => true if ENV['focus']
|
30
|
+
end
|
31
|
+
|
32
|
+
WebDriver::Platform.exit_hook { GlobalTestEnv.quit }
|
33
|
+
|
34
|
+
$stdout.sync = true
|
35
|
+
GlobalTestEnv.unguarded = !!ENV['noguards']
|
36
|
+
WebDriver::SpecSupport::Guards.print_env
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'selenium/server'
|
2
|
+
require 'selenium/webdriver/spec_support/test_environment'
|
3
|
+
require 'selenium/webdriver/spec_support/guards'
|
4
|
+
require 'selenium/webdriver/spec_support/helpers'
|
5
|
+
|
6
|
+
module Selenium
|
7
|
+
module WebDriver
|
8
|
+
module SpecSupport
|
9
|
+
autoload :RackServer, 'selenium/webdriver/spec_support/rack_server'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module SpecSupport
|
4
|
+
module Guards
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def print_env
|
8
|
+
puts "\nRunning Ruby specs:\n\n"
|
9
|
+
|
10
|
+
env = current_env.merge(:ruby => defined?(RUBY_DESCRIPTION) ? RUBY_DESCRIPTION : "ruby-#{RUBY_VERSION}")
|
11
|
+
|
12
|
+
just = current_env.keys.map { |e| e.to_s.size }.max
|
13
|
+
env.each do |key, value|
|
14
|
+
puts "#{key.to_s.rjust(just)}: #{value}"
|
15
|
+
end
|
16
|
+
|
17
|
+
puts "\n"
|
18
|
+
end
|
19
|
+
|
20
|
+
def guards
|
21
|
+
@guards ||= Hash.new { |hash, key| hash[key] = [] }
|
22
|
+
end
|
23
|
+
|
24
|
+
def record(guard_name, options, data)
|
25
|
+
options.each do |opts|
|
26
|
+
opts = current_env.merge(opts)
|
27
|
+
key = opts.values_at(*current_env.keys).join('.')
|
28
|
+
guards[key] << [guard_name, data]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def report
|
33
|
+
key = [
|
34
|
+
GlobalTestEnv.browser,
|
35
|
+
GlobalTestEnv.driver,
|
36
|
+
Platform.os,
|
37
|
+
GlobalTestEnv.native_events?
|
38
|
+
].join(".")
|
39
|
+
|
40
|
+
gs = guards[key]
|
41
|
+
|
42
|
+
print "\n\nSpec guards for this implementation: "
|
43
|
+
|
44
|
+
if gs.empty?
|
45
|
+
puts "none."
|
46
|
+
else
|
47
|
+
puts
|
48
|
+
gs.each do |guard_name, data|
|
49
|
+
puts "\t#{guard_name.to_s.ljust(20)}: #{data.inspect}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def current_env
|
55
|
+
{
|
56
|
+
:browser => GlobalTestEnv.browser,
|
57
|
+
:driver => GlobalTestEnv.driver,
|
58
|
+
:platform => Platform.os,
|
59
|
+
:native => GlobalTestEnv.native_events?,
|
60
|
+
:window_manager => !!ENV['DESKTOP_SESSION']
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# not_compliant_on :browser => [:firefox, :chrome]
|
66
|
+
# - guard this spec for both firefox and chrome
|
67
|
+
#
|
68
|
+
# not_compliant_on {:browser => :chrome, :platform => :macosx}, {:browser => :opera}
|
69
|
+
# - guard this spec for Chrome on OSX and Opera on any OS
|
70
|
+
|
71
|
+
def env_matches?(opts)
|
72
|
+
res = opts.any? { |env|
|
73
|
+
env.all? { |key, value|
|
74
|
+
if value.kind_of?(Array)
|
75
|
+
value.include? current_env[key]
|
76
|
+
else
|
77
|
+
value == current_env[key]
|
78
|
+
end
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
p res => [opts, current_env] if @debug_guard
|
83
|
+
res
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def debug_guard(&blk)
|
88
|
+
@debug_guard = true
|
89
|
+
yield
|
90
|
+
ensure
|
91
|
+
@debug_guard = false
|
92
|
+
end
|
93
|
+
|
94
|
+
def not_compliant_on(*opts, &blk)
|
95
|
+
Guards.record(:not_compliant, opts, :file => caller.first)
|
96
|
+
yield if GlobalTestEnv.unguarded? || !Guards.env_matches?(opts)
|
97
|
+
end
|
98
|
+
|
99
|
+
def compliant_on(*opts, &blk)
|
100
|
+
Guards.record(:compliant_on, opts, :file => caller.first)
|
101
|
+
yield if GlobalTestEnv.unguarded? || Guards.env_matches?(opts)
|
102
|
+
end
|
103
|
+
|
104
|
+
alias_method :not_compliant_when, :not_compliant_on
|
105
|
+
alias_method :compliant_when, :compliant_on
|
106
|
+
|
107
|
+
end # Guards
|
108
|
+
end # SpecSupport
|
109
|
+
end # WebDriver
|
110
|
+
end # Selenium
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module SpecSupport
|
4
|
+
module Helpers
|
5
|
+
|
6
|
+
def driver
|
7
|
+
GlobalTestEnv.driver_instance
|
8
|
+
end
|
9
|
+
|
10
|
+
def reset_driver!
|
11
|
+
GlobalTestEnv.reset_driver!
|
12
|
+
end
|
13
|
+
|
14
|
+
def url_for(filename)
|
15
|
+
GlobalTestEnv.url_for filename
|
16
|
+
end
|
17
|
+
|
18
|
+
def fix_windows_path(path)
|
19
|
+
return path unless WebDriver::Platform.os == :windows
|
20
|
+
|
21
|
+
if GlobalTestEnv.browser == :ie
|
22
|
+
path = path[%r[file://(.*)], 1]
|
23
|
+
path.gsub!("/", '\\')
|
24
|
+
|
25
|
+
"file://#{path}"
|
26
|
+
else
|
27
|
+
path.sub(%r[file:/{0,2}], "file:///")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def long_wait
|
32
|
+
@long_wait ||= Wait.new(:timeout => 30)
|
33
|
+
end
|
34
|
+
|
35
|
+
def short_wait
|
36
|
+
@short_wait ||= Wait.new(:timeout => 3)
|
37
|
+
end
|
38
|
+
|
39
|
+
def wait_for_alert
|
40
|
+
wait = Wait.new(:timeout => 5, :ignore => Error::NoAlertPresentError)
|
41
|
+
wait.until { driver.switch_to.alert }
|
42
|
+
end
|
43
|
+
|
44
|
+
def wait(timeout = 10)
|
45
|
+
Wait.new(:timeout => timeout)
|
46
|
+
end
|
47
|
+
|
48
|
+
end # Helpers
|
49
|
+
end # SpecSupport
|
50
|
+
end # WebDriver
|
51
|
+
end # Selenium
|