watir-webdriver 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -74,17 +74,23 @@ module Watir
74
74
 
75
75
  def double_click
76
76
  assert_exists
77
- raise NotImplementedError, "need support in WebDriver"
78
77
 
79
- @element.double_click
78
+ unless driver.respond_to?(:mouse)
79
+ raise NotImplementedError, "need support in WebDriver"
80
+ end
81
+
82
+ driver.mouse.double_click @element
80
83
  run_checkers
81
84
  end
82
85
 
83
86
  def right_click
84
87
  assert_exists
85
- raise NotImplementedError, "need support in WebDriver"
86
88
 
87
- @element.right_click
89
+ unless driver.respond_to?(:mouse)
90
+ raise NotImplementedError, "need support in WebDriver"
91
+ end
92
+
93
+ driver.mouse.context_click @element
88
94
  run_checkers
89
95
  end
90
96
 
@@ -1,3 +1,3 @@
1
1
  module Watir
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
data/spec/element_spec.rb CHANGED
@@ -2,28 +2,63 @@ require File.expand_path('watirspec/spec_helper', File.dirname(__FILE__))
2
2
 
3
3
  describe Watir::Element do
4
4
 
5
- describe "#send_keys" do
6
- it "sends keystrokes to the element" do
7
- browser.goto("file://" + File.expand_path("html/keylogger.html", File.dirname(__FILE__)))
8
- browser.element(:id, 'receiver').send_keys("hello world")
9
- browser.element(:id, 'output').ps.size.should == 11
5
+ describe '#send_keys' do
6
+ before(:each) do
7
+ @c = Selenium::WebDriver::Platform.os == :macosx ? :command : :control
8
+ browser.goto('file://' + File.expand_path('html/keylogger.html', File.dirname(__FILE__)))
9
+ end
10
+
11
+ let(:receiver) { browser.element(:id => 'receiver') }
12
+ let(:events) { browser.element(:id => 'output').ps.size }
13
+
14
+ it 'sends keystrokes to the element' do
15
+ receiver.send_keys 'hello world'
16
+ receiver.value.should == 'hello world'
17
+ events.should == 11
18
+ end
19
+
20
+ it 'accepts arbitrary list of arguments' do
21
+ receiver.send_keys 'hello', 'world'
22
+ receiver.value.should == 'helloworld'
23
+ events.should == 10
24
+ end
25
+
26
+ it 'performs key combinations' do
27
+ receiver.send_keys 'foo'
28
+ receiver.send_keys [@c, 'a']
29
+ receiver.send_keys :backspace
30
+ receiver.value.should be_empty
31
+ events.should == 6
32
+ end
33
+
34
+ it 'performs arbitrary list of key combinations' do
35
+ receiver.send_keys 'foo'
36
+ receiver.send_keys [@c, 'a'], [@c, 'x']
37
+ receiver.value.should be_empty
38
+ events.should == 7
39
+ end
40
+
41
+ it 'supports combination of strings and arrays' do
42
+ receiver.send_keys 'foo', [@c, 'a'], :backspace
43
+ receiver.value.should be_empty
44
+ events.should == 6
10
45
  end
11
46
  end
12
47
 
13
- describe "#present?" do
48
+ describe '#present?' do
14
49
  before do
15
- browser.goto("file://" + File.expand_path("html/wait.html", File.dirname(__FILE__)))
50
+ browser.goto('file://' + File.expand_path('html/wait.html', File.dirname(__FILE__)))
16
51
  end
17
52
 
18
- it "returns true if the element exists and is visible" do
53
+ it 'returns true if the element exists and is visible' do
19
54
  browser.div(:id, 'foo').should be_present
20
55
  end
21
56
 
22
- it "returns false if the element exists but is not visible" do
57
+ it 'returns false if the element exists but is not visible' do
23
58
  browser.div(:id, 'bar').should_not be_present
24
59
  end
25
60
 
26
- it "returns false if the element does not exist" do
61
+ it 'returns false if the element does not exist' do
27
62
  browser.div(:id, 'should-not-exist').should_not be_present
28
63
  end
29
64
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: watir-webdriver
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.5
5
+ version: 0.2.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jari Bakken
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-22 00:00:00 Z
13
+ date: 2011-07-11 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: selenium-webdriver