Good day to all! I wrote an application for Android (the prototype is listed below).
I studied all the tula / manuals on the compilation of a calabash test script, and also read the book "The Cucumber book". I do not understand one thing, for example at least, how to implement step defenitions on ruby to make the initial entry of a credit card number. Suppose I can write a card number in a script step,
Background: Given I press "CreditCardEntryDemo" And I press "form_with_zip" Scenario: Credit card number identity When I enter "4242 4242 4242 4242" into field with id "form_with_zip" And I check of the corrrect number of digits for the credit card Then the form should be redisplayed with CVV and MM/YY And the form should be activate a button called "Prev"
and then in step defenition write a regular expression for this number, then make a call to query ("*") to view the identifier of objects in my apk .
Questions:
1) How to connect the identifier of my CustomView field with the data that the user enters in the card number?
After running the test script and getting a hint how to implement the steps in the script
When(/^I enter "([^"]*)" into field with id "([^"]*)"$/) do |arg1, arg2| pending # Write code here that turns the phrase above into concrete actions end When(/^I check of the corrrect number of digits for the credit card$/) do pending # Write code here that turns the phrase above into concrete actions end Then(/^the form should be redisplayed with CVV and MM\/YY$/) do pending # Write code here that turns the phrase above into concrete actions end Then(/^the form should be activate a button called "([^"]*)"$/) do |arg1| pending # Write code here that turns the phrase above into concrete actions end I would like to write an implementation of these hints, for example, like something like this:
#Ввод номера карты в соответствии заданными регулярными выражениями When(/^I enter "(^4[0-9]{15}?+^5[1-5][0-9]{14}$+^3[47][0-9]{13}$+^6(?:011|5[0-9]{2})[0-9]{12}$+)" into field with id "([^"]*)"$/) do |number, idField| # TODO something end #Проверку правильности набранного номера, думаю, можно опустить из-за #регулярных выражений предыдущего шага. НО надо еще как то вернуть #сами данные в поле CustomView с id form_with_zip. When(/^I check of the corrrect number of digits for the credit card$/) do pending # Write code here that turns the phrase above into concrete actions end #После ввода номера карты, должно появиться в этом поле CustomView невидимый #CVV и MM/YY Then(/^the form should be redisplayed with CVV and MM\/YY$/) do pending # Write code here that turns the phrase above into concrete actions end #Должна стать активной кнопка "Prev" Then(/^the form should be activate a button called "([^"]*)"$/) do |arg1| pending # Write code here that turns the phrase above into concrete actions end
2) How to make abstract data entry in the test script, if possible?
That is, in the test script (see above) the card number is written "4242 4242 4242 4242".
Is it possible to check the correct operation of the application to enter any other numbers without a personal entry?
3) And how to return these numbers in the CustomView field, where in the application the user enters the data of his bank card?
Above in the comments of hints step definitions it was already mentioned about the return of a correctly dialed bank card number in the CustomView field with id form_with_zip (the description of this object is presented above). So how do you do this? :)
4) I almost forgot how to add a check for changing pictures in the input field to the implementation of step definitions?
With the correct dialing of the card number, in this input field the picture of the indefinite card should be replaced by the picture of the card that corresponds to its regular expression. For example, the number "4242 4242 4242 4242" is Visa, that is, the first picture will change to the picture of the Visa card.
Link to application prototype:
http://www.lukew.com/ff/entry.asp?1667