Global soft validation for multiple registation forms in cakephp - cakephp

I've created my website registration functionality using six different steps with different forms..now i want to create
global soft validation for all six steps..
suppose i am new website user..now i clicked on directly registration step 3 then i can able to go directly step 3 without
enterting information for step 1 and step 2..now suppose clicked on previous step from step 3 then i want one global validation array for step1 and step 2..
which will be display on step 2 form when i clicked on previos step from step 3..
If any one have idea about then please let me know ASAP..

You could have a look at the 'validating data from the controller' chapter. You have to write some logic and checks to see which steps/fields been set:
http://book.cakephp.org/2.0/en/models/data-validation/validating-data-from-the-controller.html

Related

Only 2 steps are different when compared to two feature files. (cucumber-selenium-java)

I am learning cucumber. I have two scenarios. I can't say the exact due to company policies. First Step file is like
Scenario 1: Flow with attachments
Given Login to APP
When User chooses "country"
And clicks "Yes"
And attaches "files"
And Go to location page
And add comments
Then Submit
Scenario2: Flow without attachments
Given Login to APP
When User chooses "country"
And clicks "Yes"
And add players manually
And User picks players
And User clicks on a player
And does the settings
And Go to location page
And add comments
Then Submit
Do I need to write all the steps again in Scenario 2 or can I do something so that I can bypass writing all the steps in feature file.
I mean can I maintain only different steps in the 2nd feature while like we do in writing step file or glue code for that.
If yes how to do it, so that it run all the previous steps. Please help
Instead of writing all the steps in terms of small actions the users performs on the system (like "go to page", "click this" , "submit that"), think about what the user is trying to achieve and create a step that describes that in a way that is meaningful to the user (i.e. "add players from a file", or "add players manually"). The step definition for that step will then contain all of these actions on the system (click this, fill that, etc). You can also use what we call "helper methods" from your step definition; for example create a method that will navigate to a certain page, and call that method with the relevant page to go to from your various step definitions.
That way your scenarios will describe the intended behaviour of the system, or what the user is supposed to be allowed to do (or not do).
Also, from the examples you've provided it is not clear to me what it is you are testing/asserting. I've always found it helpful to use "Given/And" to set up the original state of the system, "When/And" for the actions to be performed that you want to test the outcome of, and "Then/And" to verify the expected result.
The title of the scenario should clearly describe what it is the scenario tests for.
From your example, I've assumed that you are testing that a user is able to add players either from a file or manually. In that case, the scenarios could look something like the following:
Scenario: User is able to add players from a file
Given a user who is logged in
And the user has selected "country"
When the user attaches "files"
And adds a comment about location
Then the players are added
And the comment is saved
Scenario: user is able to add players manually
Given a user who is logged in
And the user has selected "country"
When the user adds players manually
And adds a comment about location
Then the players are added
And the comment is saved
In the example above, I am also assuming that the following steps:
And add players manually
And User picks players
And User clicks on a player
And does the settings
are actually all (always) needed to add players manually, so all of those actions would be performed in the one step "And add players manually" (either by implementing them all in one step, or calling several helper methods from that one step).
By describing the behaviour like this it is much clearer what you are testing in each scenario and what the expected behaviour of the system is.
Also, it will lead to way less duplication of "steps" (as was your original question, I believe).

How to handle common steps in Behave

I have 4 feature files like login, add to cart, search by product, shipping method calculation. All 4 are separate feature file and all have first 4 steps are exact same like below :
Given I go to website
When I click on the login button
Then I enter username and password
And I verify I am logged in successfully
In behave if I use the same steps in all feature files, it does not work. It has an Ambiguous Step error.
My goal is to log in first in all 4 feature files and then move to the next corresponding step.
The error I am facing :
raise AmbiguousStep(message % (new_step, existing_step))
behave.step_registry.AmbiguousStep: #given('I am loggedin into website') has already been defined in
existing step #given('I am loggedin into website') at features/steps/Steps_cart.py:5

Uploading file on Step in Bonita

i would like to upload and download a file. I know the FileUploadDownload Example but i required to upload document on step not on instantiation form.how can i achieve that i have made contract on step and assigned it to document variable initialized at pool level, but its not working. it gives error that "Error submitting form". I am new to bonita help anybody.
Steps for process building are given as follows:
Step 1:
Step 2:
Step 3:
Step 4:
Error:
When i submit form Error generates which is given as follows:
To solve your issue, you need to remove the contract inputs on the process instantiation, change the default value for the document variables and remove the process instantiation form:
Remove contract inputs
Select the pool.
Go to Execution -> Contract.
Remove the file inputs.
Document variables default value
Select the pool
Go to Data -> Documents
For each variable, Edit -> Select None in Initial content
Process instantiation form
Select the pool
Go to Execution -> Instantiation form
Remove the current Target form
That should do the trick :)
Also, check the new version of the file upload example, I removed the limitation that duplicate the document each time the steps is submit:
https://github.com/Bonitasoft-Community/file-upload-download-example
Cheers

Drupal 7 Multistep forms - Remove save & preview button until last step

I have made a multistep/page form in Drupal (the field type is a multipage group, with multipages nested).
The form is 6 pages, and there is required info on every page. The problem is, Drupal puts a "Save" and "Preview" button on the bottom of every page of the form. Really, you CANNOT preview the form or save it until all required fields are filled out. So when users are going through the form and they hit "save" halfway through or "preview" halfway through, they get a ton of errors.
Is there any way to remove the "save" and "preview" buttons until they are on the last page (i.e. page 6 only)?
Thanks.
EDIT: I am using Field Groups to build my form by the way.
There isn't any module I found to do this, not in it's entirety anyway.
We ended up removing the preview button completely with CSS, and installing a module (Required For Publishing) that allows you to specify "Fields Required for Publish" vs fields required to save a draft. Now there's only 3 fields to save a draft for later, but 20+ fields required to publish the event/form.
We used javascript in the multipage.js form to validate on each step so they can't move on without filling out the actual required fields on each page.
You'd have to make your own module and use hook_form_alter .. https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_form_alter/7 .. and check which step you are currently on .. and then remove the buttons if you are not on the last step .. and enjoy.
Something like .. unset($form['actions']['preview']);

Selenium: how to execute every element in a page

I want to use selenium to test every possible user actions in a web application. For example there are 2 paths in an application like pageA->pageB->pageC->pageD; pageA->pageB->pageE and we use a list to store the elements on pageB. I want to use a for loop to test every element in this list.
The problem is: after testing the first path, how to go back to pageB to execute another user action? Is this a method to record the state or position of pageB so that can go back to pageB then test the second element?
Many thanks in advance!
I think the best thing to do is to test the real behavior of a user. So you can either create 2 tests, one for each path, or one test with the first path, then go back in the history using Navigation.back (or with navigation button provided by your website) and then go to page E.
The first solution is nice because you got 2 independent tests, the second is useful if you need to test some side effects of the first path.

Resources