Skip to content

Commit

Permalink
added enter_text method to WebView
Browse files Browse the repository at this point in the history
  • Loading branch information
cheezy committed Jun 16, 2013
1 parent 6b74374 commit 5f8c123
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Added WebView view class with these methods:
* has_element?
* click
* enter_text

=== Version 0.7 / 2013-6-8
* Enhancements
Expand Down
4 changes: 4 additions & 0 deletions features/step_definitions/webview_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@
@webview.click('textContent', text)
end

Then(/^I should be able to enter "(.*?)" into the text field$/) do |text|
on(WebviewScreen).scroll_down
@webview.enter_text('id', 'tf', text)
end
6 changes: 5 additions & 1 deletion features/webview.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ Feature: Adding support for webviews
| tagName | p |
| textContent | Six columns |

@focus
Scenario: Clicking on a web element
When I look for elements in the webview
And I click on the anchor with the text "Some Other Page"
Then I should see the text "Welcome to Some Other Page" in a webview

@focus
Scenario: Entering text in a web element
When I look for elements in the webview
Then I should be able to enter "Some Text" into the text field
18 changes: 15 additions & 3 deletions lib/gametel/views/web_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ class WebView < View
WEB_VIEW_CLASS = 'android.webkit.WebView'

def click(how, what, index=0, scroll=true)
platform.chain_calls do |device|
device.web_view_by(how, what, :variable => '@@by@@', :target => :Brazenhead)
device.click_on_web_element('@@by@@', index, scroll, :target => :Robotium)
find_element_by(how, what) do |device, by|
device.click_on_web_element(by, index, scroll, :target => :Robotium)
end
end

def enter_text(how, what, text)
find_element_by(how, what) do |device, by|
device.enter_text_in_web_element(by, text, :target => :Robotium)
end
end

Expand All @@ -17,6 +22,13 @@ def has_element?(how, what)

protected

def find_element_by(how, what)
platform.chain_calls do |device|
device.web_view_by(how, what, :variable => '@@by@@', :target => :Brazenhead)
yield device, '@@by@@'
end
end

def build_property_methods
metaclass = class << self; self; end
properties.each do |property|
Expand Down

0 comments on commit 5f8c123

Please sign in to comment.