Giter Club home page Giter Club logo

Comments (14)

jonasmaturana avatar jonasmaturana commented on June 19, 2024

I will change the step so that it clears the input field before entering text. That means that if you enter an empty string it will only clear the field.

from calabash-android.

jonasmaturana avatar jonasmaturana commented on June 19, 2024

I just released calabash-android-0.0.16.
It clears the input field before entering text. That means you can write the following steps.

Given /^I clear the first input field$/ do
  set_text "webView, css:input[type=text]", ''
end

Given /^I enter "([^"]*)" into the first input field$/ do |text|
  set_text "webView, css:input[type=text]", text
end

from calabash-android.

atcrao avatar atcrao commented on June 19, 2024

Please help me understand, I am also new to cucumber.
Looking at the above step, shouldn't I provide css locator as an input.

Given /^I enter "([^"])" into the input field "([^"])" $/ do |text, locator|
set_text "webView, css:locator", text
end

For example:- Given I enter "[email protected]" into the input field "input#email"

from calabash-android.

jonasmaturana avatar jonasmaturana commented on June 19, 2024

This should work if you want to give the css selector as an argument.

Given /^I enter "([^"])" into the input field "([^"])" $/ do |text, locator|
  set_text "webView, css:#{locator}", text
end

However, it is more readable to do something like:

Given /^I enter "([^"])" as email" $/ do |email|
  set_text "webView, css:input#email", email
end

That way you keep your test in a business language without exposing technical details.

from calabash-android.

atcrao avatar atcrao commented on June 19, 2024

Thank you . This works as desired
Given /^I enter "([^\"]*)" as email$/ do |email|
set_text "webView, css:input#email", email
end

But the below step doesn't clear the input field. I still see the old text exists in email field.
Given /^I clear the first input field$/ do
set_text "webView, css:input#email", ''
end

I did install the latest gem and I unpacked the gem and noticed the set_text(uiquery, txt) method is defined operations.rb.

from calabash-android.

atcrao avatar atcrao commented on June 19, 2024

Continuation...
Jonas, it will be great if the logic to clear the text field in web view works. Currently I am not able to test any end-to-end webview flows as the signin itself fails.
Thanks in advance.

from calabash-android.

jonasmaturana avatar jonasmaturana commented on June 19, 2024

Did you update calabash-android to 0.0.17? It should clear the text field.

Run gem update calabash-android to update.

from calabash-android.

atcrao avatar atcrao commented on June 19, 2024

Yes, I do have 0.0.17.

The non-empty string works-
Given I enter "[email protected]" as email

The below empty string doesn't work-
Given I clear the first input field
Given I enter "" as email

The step definition are defined as you described:-
Given /^I clear the first input field$/ do
set_text "webView, css:input#email", ''
end

Given /^I enter "([^\"]*)" as email$/ do |email|
set_text "webView, css:input#email", email
end

from calabash-android.

jonasmaturana avatar jonasmaturana commented on June 19, 2024

Does this work as expected?

Given I enter "foo" as email
Given I enter "bar" as email

from calabash-android.

atcrao avatar atcrao commented on June 19, 2024

Yes, it worked.
The only time it doesn't work is when I give ""

from calabash-android.

jonasmaturana avatar jonasmaturana commented on June 19, 2024

Just to be sure. After you you run the to steps above the input field has the value "bar", right?

What about entering a single space into the field?

It might have something to do with a listener on the field in your app. Do you know if there is such a listener?

from calabash-android.

atcrao avatar atcrao commented on June 19, 2024

There is email-id already populated in the username field. When I enter the value "bar" then the "bar" is appended to the already existing text.
For example:- The username field is pre-populated with value "[email protected]", and when I invoked the step 'Given I enter "bar" as email', the value in username field is changed to "[email protected]"

When I entered a single space into the field via the step 'Given I enter " " as email' then I noticed the username field is appended with single space "[email protected] "

My original request for filing this issue is to clear the content in the username field before entering a new username.

I will get back to you regarding the listener.

from calabash-android.

jonasmaturana avatar jonasmaturana commented on June 19, 2024

There seem to have been a bug in 0.0.16 so that the text is not cleared. Could you try to update to 0.0.18?

from calabash-android.

atcrao avatar atcrao commented on June 19, 2024

Thanks a lot. It works after upgrading to 0.0.18.

from calabash-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.