Cucumber scenario with same buttons? - cucumber

This is my first time doing cucumber, so maybe what im asking isn't wrong but it just seems like there is a better way:
So right now im going through a survey-like website as my first automation task with cucumber. It works just fine, but like most surveys theirs a lot of "Fill then out, then click Next"
so in my Feature file I have a lot of:
Then I will click 'Next'
Which matches with the step (Since the button all have the same text):
Then(/^I will click 'Next'$/) do
click_button('Next')
end
So this one step definition defines like 8-9 lines in my feature file...which I guess is ok, but my feature file just looks...ugly? Im not used to the Gherkin language AT ALL as this is my first time, but it's basically turned into a lot of:
THEN SELECT THAT THING FROM DROPDOWN
THEN CLICK THIS RADIO BUTTON
THEN SELECT THIS BUTTON
THEN CLICK NEXT
Like over and over....I mean it's human readable, but it just looks messy? is this right?
Also im not really sure when I should use "explicits" in my feature file? Like should I explicity say Im going to select 'X' (or "X", not sure if it matters) from a dropdown? or Click the 'Next' button or select the 'yes' radio button for example?

You are writing what are called imperative steps and it is indeed the wrong way to go about cucumber/gherkin.
Your steps should be saying "WHAT" you are doing and not "HOW" you are doing.
Not knowing the details of your form, let's make up a flow.
Page 1. Name
Page 2. Demographics
Page 3. Favorite football team
Page 4. Favorite basketball team
Page 5. Results page showing how popular their teams with other survey takers
Given I enter the "Are you a Bandwagon Fan Survey"
When I enter my name
And I enter my demographics
And I choose a favorite football team
And I choose a favorite basketball team
Then I should be directed to the result page
And I should see my teams ranked on a graph
The details for entering your name and clicking next should be hidden inside that stepdef. A person trying to test your app doesn't care what the name is, or what the field ID is or anything like that. They just want to know the work flow.
If you are doing scenarios to get the name page to error you simply modify your gherkin to say something like.
When I enter a name too long
Then I see a name too long error message
When I do not enter a name
Then I see a name missing error message
Again, you leave the details of too long or what the error message is to the step def (or below) unless it is critically important to the test scenario. I usually set up factory girls to handle my data and just use the text of the scenario to pull the current data. so I'll have an error message factory and within that a "name_missing" and a "name_too_long" sub-factory that provide the correct values. If I need to change or look something up, everything is in the same place...but above all it's not cluttering my gherkin.

Yes I think you want to send parameters to step definition
Then I will click 'Next'
Step definition will be
Then(/^I will click "([^"]*))*"$/) do |text|
click_button(text)
end
also above will work for
Then I will click 'OK'

Related

Indexing Bixby Spoken-Summary

I received help on getting Bixby to read the list in the view, but now I am trying to have it be useful for Hands-Free List Navigation. Is there a way use indexing in Spoken-Summary? Currently it just reads each item in the list, but it will be difficult to use ordinal selection without indexing.
Indeed where-each does not have child-key index-var. You can add an index property in the concept structure and add index value in your JS file as a workaround.
However, I would think the speech itself should be sufficient in selecting content. In case of read-one Bixby will pause after each item waiting for "next" or "yes". In case of read-many developer can set page size.
You can (maybe should) implement your capsule that it takes the content rather than number.
For example: "watch news" --> "which of the following channel would you like" --> "BBC, NBC, CNN, FOX", at the input prompt, rather than auto answer machine, "press 1 for BBC, press 2 for NBC... ", user should be able to say "CNN" or "CNN News" and it will match as an input.
In case you really need index, the current possible work around is to add index as part of the structure in your JS function returning the list. It should not be hard. The voice command of "first", "second"... "last" are built-in features and should work.
You can also go to developer center and make a feature request to add index-var to where-each, but it will be a PM decision to approve or when to implement such feature.

basic blue prism email login object

Trying to learn basic blue prism.
I have made an object to login to my gmail account.
It enters the page where mail id has to be entered. The email id gets entered and the next page appears where the password has to be entered. But in the writer tool it shows the following message : "Internal : Failed to perform step 1 in Write Stage 'Writer2' on page 'Initialise' - No elements match the supplied query terms"
I looked into all the most obvious bugs and I cant find anything wrong. Can someone please give any suggestions as to what the problem could be?
The specific error message you're getting indicates there's an issue with your spying of the element you're attempting a Write on.
Without knowing anything else about the way you've included/excluded certain attributes of the element you're attempting to write to, the only sound advice one could offer would be to open the Application Modeler and trial-and-error the "Match?" for each attribute until you're able to use the "Highlight" button and verify a single interface element is selected. (Usually in circumstances such as yours, the "Value" attribute of the element you've spied has its Match checkbox selected, but the value has changed since spying it, thus making it not a match.)
check if the data item you are storing the password in is of password type.
You can reset the password by going ahead with the "write" property and delete once and drag-drop again at the same place and click OK. reset the flowchart and run them again, you'll not get the error. I had faced the same issue earlier and got fixed.
It sometimes happens due to the slowness of your internet connection BP not able to read the data item info and directly moved to next steps, to fix it, you can use wait functionality and give the 8-10 sec of wait time.
Hope this helps.
stay blessed!
When spying a browser please make sure you are using HTML mode to capture the necessary Element (please note that BP only supports IE, so no Chrome or other browser!). Also, please remember that the browser page you are spying has to be launched from the Application Modeller in order to be "attached" by BP.
To cycle between modes, simply hit the Alt key after clicking "Identify" on the Application Modeller. After you have captured the correct area of the page where your password goes, uncheck all the attributes of the element that are blank and also the URL attribute (you should be left with 4 maybe 5 atributes left), then hit "Apply" and "OK". Click "Highlight" to make sure BP still finds the element of the page that you want. Then in your Process or Object canvas, use a "Write" stage and drop this element you just created in the Element field, and the password into the Value field (the value has to be between "" unless you are using a data item instead of typing it in). If you have done all this, the "Write" stage should most definitely enter the password into the password field. Good luck!

How to put a limit of the clicks on the button in real time?

I have a question recently: How can we realize the restriction on the button clicks in real time?
For example, there is a restriction in 10 clicks on a button. For example Bob clicked on the button and then Bob and Rob saw that there stayed 9 clicks. After the 10th pressing the button is disabled.
What will you advise?
Use a database to track the number of clicks
Depending on your functional needs, you probably want to be on the "immediate consistency" end of the spectrum vs "eventual consistency" so either use a traditional relational database with constraints and transactions or store the clicks in a single mongodb document you can update atomically.
MongoDB You might set up a ClickTrackers collection and a document like:
.
{
button: "reserveSeat":
clickedBy: [userId1, userId2]
}
Then you could use $addToSet
a redis set might work well (assuming you are allowing 1 click per user)
You will want some real-time libraries to help you push updates out to connected browsers. Perhaps meteor.js or socket.io.js
There's no way to avoid the edge case of lag between showing a user there's 1 click left, someone else clicking it, and then the first user clicking it before the click count decreases to 0 (like buying tickets to a popular concert, for example), so you must handle this and write tests for it and have a UI to say to the user "oops no clicks left, actually, sorry"
Hopefully that gets you started, but as it is your question isn't following the stackoverflow guidelines as it is "too broad" and you haven't posted any code you've tried, so go try something and come back with some code snippets.

How to add action in then section of cucumber?

I'm new to cucumber and I wonder how can I test the following scenario:
user, that is not signed in, clicks on "buy" link on my site
popup with login/passwords shows
user fills login and password fields and then click 'Sign in'
page reloads
user clicks again on "buy" link and see popup with order details
I have problem with defining "Then" section, because for me it should be:
Then
When I click "buy"
I should see "order details"
Is this possible with cucumber?
Scenario should have a single testing goal. With your current scenario you have 2 goals so it may be better to write 2 scenarios:
Possibility of login after clicking buy
Ability to see order details after clicking buy.
I don't understand why you want to do this using 1 scenario.
That said, Cucumber doesn't distinguish between Given, When and Then at step definition layer so you can write like this:
Given ...
When ...
Then ...
When ...
Then ...
The feature file would look like this (simplified):
Feature: View Order Details
As a user I can process an order
Scenario: Process Online Order
Given I am logged in
When I click "buy"
Then I should see the order details

Can "Excel Add-In for Coded UI Testing" help when reading test scenario data from Excel worksheet

This requires a detailed explanation.
Imagine that I have an Excel spreadsheet with test cases in one worksheet
and I may have expected (validation) messages in another (in addition to expected messages in the first worksheet).
There is also some linking between the values of fields in one to the second worksheets.
See: Welcome, <First Name> <Last Name> as an example.
You can see in the "Expected Results" field in "Test cases" worksheet the value of the field is:
"The user is taken to My Account page and following welcome message is displayed:
"&Messages!$B$1244&", where First name is Dave and Last Name is Brown."
so "&Messages!$B$1244&", denotes field B1244 in worksheet "Messages"
Now the question.
If I am given all test cases like the example below for an ecommerce web site, how can I use Coded UI Testing based on this input? Can I automate Excel, use the steps in test case worksheet and combine that with Coded UI recording of data input and verification.
I believe I would need to do manual coding, partially using recorded input steps and verifications from Coded UI recorder and possibly using manual programming for verification.
I would like to hear if others have done something similar.
I would like to incorporate this into Specflow BDD, by writing feature/user story and these test cases will be scenarios.
Any success, thoughts on using Excel test automation as data driven testing.
Thanks
Rad
Test cases worksheet named "Test cases":
=====================
Test Case Name Test Case Objective
frontstore.01-3 Register a shopper from order
confirmation page with valid inputs
# Step Data Expected Results
------------------------------------------------------------------------------------------------
1 Launch the test storefront http://testserver.com/index Welcome page is loaded.
2 Click Sign In link Sign In page is loaded.
3 Click Register under New Customer Register page is loaded.
4 Enter valid inputs and click Submit "Logon ID = TestUser
Firstname = John
Lastname = Clark
... (other fields) Registration Successful.
The user is taken to My Account page
and following welcome message is displayed:
Welcome, <First Name> <Last Name>, where First name is
David and Last Name is Brown."
Validation Messages worksheet named "Messages":
=====================
#Text used in MyAccountPages
---------------------------------------------------------------------------
MA_WELCOME Welcome, <First Name> <Last Name>
After reading a bit about Coded UI testing:
It can certainly be done, but data/sentences like:
“Launch the test storefront”
“Click Sign In link”
“Registration Successful.
The user is taken to My Account page
and following welcome message is displayed:
Welcome, , where First name is
David and Last Name is Brown."
contain both actions and data so I need to drill down into parts of the sentence to
translate it to actions and binding to parameters.
If I understand well data binding can only be used to bind column values to some parameters.
So I need some way to automatically recognize the meaning of these sentences and use some binding
from parts of it.
So if I have a sentence:
“Launch the test storefront” that would be translated to:
CurrentBrowser.Navigate(Helper.TranslateTargetUrlFrom(“test storefront”))
where “test storefront” might resolve to http://testserver.com/index storefront home
page and I can ignore Data column for URL
or I can capture Launch keyword to mean CurrentBrowser.Navigate(ColumnValue(Data)) and ignore “test storefront” part of the sentence.
“Click Sign In link” could be translated to CurrentBrowser.FindLink(“Sign In”).Click(),
so it this case I will need to know that Sign In is
the text of the link, again I need to extract “Sign In” to mean the text of a link.
I see this as pretty manual style of CodedUI where I could do small recording for some actions and rely on manual extractions of terms from
given sentences.
I would like to know how can I semantically write better test cases to allow automation. I would probably need some kind of free form
test case parser that would recognize the semantic meaning of some words like: click, navigate, launch, enter, click under etc and translate this into
code by re-using existing helper methods and recorded actions and do some manual binding, but not with the whole data value in the column, but
an extracted value.
Any idea of this kind of automation?
I think yould could do this by data binding the input parameters and just reading Excel as a datasource, you are going to need to use CodedUI for that not MTM + Fast Forward

Resources