I am using Calabash Android for automation testing. My app has a facebook login button and after click on it. A web view is opened, how to enter text in usename and password field?
1
-
Are still experiencing any difficulties? Was the answer below helpful? – Dmitry Cheremushkin Jul 9 '14 at 0:13
Add a comment
|
There can be at least 2 solutions.
1st possible solution:
Then /^I login to Facebook with "(.*)" email and "(.*)" password$/ do |email, pass|
set_text("webview css:'input[name=\"email\"]'", email)
set_text("webview css:'input[name=\"pass\"]'", pass)
touch "webview css:'button[name=\"login\"]'"
end
2nd possible solution:
Then /^I login to Facebook with "(.*)" email and "(.*)" password$/ do |email, pass|
touch("webview css:'input[name=\"email\"]'")
keyboard_enter_text(email)
touch("webview css:'input[name=\"pass\"]'")
keyboard_enter_text(pass)
touch "webview css:'button[name=\"login\"]'"
end
keyboard_enter_text
method here is from Calabash Android: enter text from keyboard post.
def keyboard_enter_text(text)
processed_text = text.gsub(/([^\w\s])/) { |c| '\\' + c }
processed_text = processed_text.gsub(' ', '%s')
input_command = "#{default_device.adb_command} shell input text #{processed_text}"
raise "Could not send keyboard text: #{text}" unless system(input_command)
end