How to enter text in the username&password field in Facebook login window (calabash-android)



  • 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?



  • 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



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2