Gherkin not recognizing examples for scenario outline - parsing

I'm new to writing features in gherkin, and am getting an error on my very first scenario outline.
#language:en
Feature: Create an account
In order to become a member
As a new user
I can create an account
Scenario Outline: View the account creation page
Given I am at the "<page>" page
And I have selected "<lang>" language
When I see the Sign Up link in my language
And I click the "<size>" Sign Up link in my chosen language
Then I see the User Account page in my chosen language
And the Create New Account tab in my chosen language
Examples:
|page |lang |size |
|landing |English |large |
|landing |English |small |
|FAQ |English |large |
|Forums |English |small |
|landing |Francais |large |
|landing |Espanol |small |
When I run
cucumber --dry-run
I get the following error:
Missing Examples section for Scenario Outline at [filename].feature:8
(Cucumber::Core::Gherkin::ParseError)
Originally I had the variables in angle brackets without quotes, and added quotes following the suggestion here but alas, it didn't help with my situation.
Any ideas what my mistake is?
Thanks!

Related

How do you print different templates in netsuite?

I am trying to find the correct template and id to use for a hotprint of an advanced pdf template of an Item Fulfillment.
The hot print url is (with the id bolded) https://system.na3.netsuite.com/app/accounting/print/hotprint.nl?regular=T&sethotprinter=T&id=7600&label=Packing%20Slip&printtype=packingslip&trantype=itemship&orgtrantype=TrnfrOrd&auxtrans=7605
For some reason only certain id=# seems to affect the outcome and the ids I have got to work for two different templates don't match the Custom Transaction Forms ID or the Advanced pdf script id. (example most ids=template 1, while 168,4954, and seemingly random other ids=template 2) I am very confused on how netsuite resolves the hot print url as it normally doesn't include the template= part though I have seen others use it for invoice print urls.
The parameters at the end of the url (the stuff after the ?) are used by Netsuite to control settings used by the webpage which prints the PDFs for you.
In this case, &id=##### refers to the internal id of the document you are printing. You can see this by going to the document, right clicking, selecting inspect, and typing nlapiGetRecordId() into the console. When you click Print, you should see that same number after &id=#####.
&template=### refers to the template you are printing. If you go to Customization -> Forms -> Advanced PDF/HTML Templates, you'll notice a Script ID field in the table. If you substitute the correct Script ID in for the number in &template=###, you'll notice you generate the same PDF. This Script ID acts the same as the number that was previously there.
The reason you're seeing unusual results when you change those numbers is because you're mismatching a record with a template not built for it. So it won't print exactly right, but will sometimes execute anyways.
Anyways, this sort of parameter scheme is a similar scheme to how Suitelets and Restlets work, so in the future, you might experience this sort of thing again.
EDIT: For those reading this in the future, please read the comments.
To customize a packing slip and return form:
If you are printing packing slips and need some customization, you can use a custom invoice form when printing packing slips. For example, you can customize an invoice form to hide the fulfilled item tax rate and amount, and the order total. Then, when you print the packing slip using the custom form through mass print, choose the the packing slip shows the customized information.

Asana * Wufoo : Advanced integration

I am working on "Advanced integration" of a forms from Wufoo to Asana. SO far I have followed the Asana guide - https://asana.com/guide/help/api/wufoo
Guide is excellent and everything within the guide work as it says, but I need to go a bit further.
I notice that there is a bit of symbols that asana recognize from the forms( like quotes"" , equal ==, question mark ?), example of multiple choice menu:
"Chose person" == "asana tag" ? 1559453678421
"Chose person" == "asana person" ? blablabla#something.org
So in the following example I can have a multi choice menu that can assign task to a person and/or put a tag.
If I add a second person, that person become a follower, which is great.
My goal:
I want to make the form filler to add its email address, and that email address to be add as follower of the task.
What I know:
I have so far talked with Wufoo support and they told me that the text from the form goes in a straight text form to Asana, and asana actually recognize the form and create the specific tasks, for example:
<strong>This become BOLD text in asana</strong>
I keep on looking for the rest of the recognized symbols, but without success so far. If you have any kind of information regarding the "Advanced integration" I would love to know.
(I work at Asana.) Right now we only support routing through fields that are hidden (have the "hide" classname) with our Wufoo integration, but your use-case is very interesting. I'll take a look and see if we can enable this.
I have found a 2 workarounds to make this work for me.
Workaround 1
So far I have discover that asana recognize "hide" CSS Layout and the field labels : project,tag,assignee,follower . If these values are true then to make this editable I add a Wufoo form Rule that can show/hide fields. for example :
If "Email" contains "#" show "assignee"
And that rule does not change the CSS Layout Keyword "hide" so the form is send the same way with the only difference that the "hide" field is actually visible and that make it easily editable.
Workaround 2
By keeping the fields hide you can still edit them with "URL Modifications ". So basically have 2 forms linked together, so the first form fill up information that is send to the second form within the URL, so the fields remain hidden but being filled up by the URL. - I have not played with that much but Wufoo support briefly explain to me that its possible
URL Modification reference - http://help.wufoo.com/articles/en_US/SurveyMonkeyArticleType/URL-Modifications

Add a pop up box for each user/IP to see just 1 time

I don't know exactly what to search for when looking for info on this so here we go...
I've recently made a change to my MVC website (all the code parts are VB, not like most examples which tend to be in C#).
Once a user logs in, is there a way to show that user a pop up box, or a div, which simply explains the changes made (the text in the box is not important).
I only want the user to see this ONCE!
Example:
As soon as the user goes to the URL, they get a pop up box saying "You now have to add your name when creating a new post"
But of course, the user doesn't want to see this EVERY time they log on to the page.
Any pointers would be lovely,
Cheers.
You would need to in some way track that users have seen the message. If there's any likelihood that there will be future such messages, maybe any value in tracking when users saw the message, etc. then this can all be put into a fairly simple database structure.
Maybe a lookup table of messages:
ID | Message
-------------
1 | "This is the text of the message, or maybe the whole HTML, or some other data, it's up to you."
2 | "Other message, etc."
And a table to link that to users:
UserID | MessageID | DisplayedOn
--------------------------------
123 | 1 | 2014-01-30 08:56:21
You can even make the messages more "interactive" and have an "Accept" or "I Understand" button, requiring that the user accept the message or see it again until they do. For something like that you can change DisplayedOn to FirstDisplayedOn (maybe include a LastDisplayedOn?) and also an AcceptedOn to track that interaction. This could be very useful for updates to terms of service, for example.
Then when a user logs in, when you fetch the overall user context/object from the database you would include any messages they need to see, haven't seen yet, haven't accepted yet, etc. Your UI can then display whatever it needs to display based on that.
As you want to show popup only after user has logged you need to store information about who has seen this popup. I am guessing that you already have database and data access layer all set up. So, you need to add a new table with following columns:
Id | UserId | PopupId | ShownOn
Before displaying popup you need to query this table to see if user has already seen it. If not, just show the popup and insert a new record in data table.
As we don't know how you access your data it is impossible to give more precise solution.

How do I do if statements in Cucumber scenarios?

My app has permissions, and certain tests need to not be run when a particular permission is on, and some tests need to be run when that same permission is on.
Is there a way to do this? or do I need to use a different framework?
The standard way of excluding 'tests' in Cucumber is to add a tag to them to identify them, then when invoking Cucumber you specify which tags to include/exclude. In your example, you could tag a specific scenario:
#needs_permission
Scenario: View users billing information
Or tag the whole feature:
#needs_permission
Feature: Administrative area
Scenario: View users billing information
Or tag certain examples in a scenario outline:
Scenario Outline: Visit a page
Given I visit "<page>"
Examples: Don't need permission
| page |
| index |
| sitemap |
#needs_permission
Examples: Do need permission
| page |
| admin |
Now, when you run Cucumber, you can exclude those tags if necessary:
When the permission is on and you want to run all tests:
cucumber .
When the permission is off and you want to exclude the tests that need it:
cucumber . -t ~#needs_permission
An alternative which I have used with mixed results, if you really don't know ahead of time, is to mark a step as pending if it doesn't apply given the current scenario, e.g.
Given /^I visit some page which needs permission$/ do
pending "Permissions aren't enabled - skipping" unless permissions_enabled?
end
This will mark the step as 'pending' which really means 'not fully implemented', which isn't ideal, especially if you have many such steps - it can be difficult to ensure that other unimplemented steps don't accidentally creep in and get hidden by all the ones you've deliberately marked as such.
We get a similar instance of this a lot, we have 2 solutions,
either tags as suggested, or
create different scenarios for different permission types:
Given i log in as a moderator
and there is a new post
when i view the post
Then i should see a delete button
Given i log in as a normal user
and there is a new post
when i view the post
Then i should not see a delete button
May be possible using tags. Difficult to say without more detail.

Is there a way to Test (Unit/Integration) that CSS is applied to the expected HTML Elements?

I am testing views with Cucumber and Rails right now and really enjoy the experience. I can easily say:
Background:
Given I am logged in as a customer
Scenario: View the Welcome Page
When I go to the home page
Then I should be on the "Welcome" page
And I should see the following in the sidebar:
| selector | text |
| h3 | Search |
| .home-page | Home |
| .about-page | About |
Now I'm wondering, how can I go one step further and say:
And I should see the following colors on the "Welcome" page:
| selector | background |
| #content | white |
| #sidebar | grey |
| #navigation | blue |
I feel like I saw that it is possible to do this with something like Node.js or other serverside javascript, because it's all browser dependent. Is there a way to do this, maybe with Selenium in just Safari and Firefox?
I just want to test for mainly colors and fonts, not necessarily layout b/c of the cross browser craziness. How could I do this? Maybe a little Jasmine with Cucumber?
Thanks!
Update
Thanks to #idlefingers, here's something that works:
Setup: Cucumber, Capybara.
features/support/env.rb:
Capybara.javascript_driver = :selenium
*features/step_definitions/css_steps.rb:*
Then /^I should see the color "([^"]+)" on the ([^"]+)$/ do |color, selector|
element_color = page.evaluate_script('$("##{selector}").css("border-left-color");') # "rgb(221, 221, 221)"
assert_equal color, some_color_conversion_method(element_color)
end
features/some.feature:
And I should see the color "red" on the sidebar
If there's a better way, I'd love to know!
Sometimes the requirement is that an element is a certain color. It is possible to test this with tools such as Jasmine, but since you want to validate the final display is right, a browser-based integration test is the right tool. (To get this to work in Jasmine, you'd have to do quite a bit more work and end up with a less valid test... anyway...)
I wrote a simple jQuery plugin called Color Spy to be able to query an element about its colors. You can ask:
$(...).backgroundColor()
$(...).colorColor()
The plugin traipses up the DOM calculating the color.
To get this to work within the context of a selenium test, you will need to:
make sure the plugin is available. You can just include this in your page, or there are various ways to pull this in dynamically.
write an element_color(selector) test helper function. This will need to use the whole get_eval shenanigans to execute some Javascript dynamically.
Use assert_equal as normal. (I also have some Javascript function in my jsutils repo to assert "visual closeness" of colors-- but that's a different question.)
Hope this helps.
I can understand why you might want to check that the correct id or class has been applied to an element, but I can't see why you'd want to check it's css directly? That'll be so brittle - simply changing the shade of the colour will break your tests!
Also, I think you're missing cucumber's main strength - testing behaviour, not implementation. You should have a read of this - it makes some good points which are pertinent to the way you're currently testing.
In answer to your actual question, if you really want to do this, the only way I can think of is to execute javascript on the page to test the values. This can be done in selenium (with get eval). The same thing can be achieved through capybara so long as the js driver is working.
You could use Webrat (which uses Nokogiri) to test the HTML body response: http://cheat.errtheblog.com/s/webrat/
Then you can do:
assert_have_selector "#content.white"

Resources