I am writing in Feature file where I need to display error message
Here is my code:
Scenario: Registration of Client with alphanumeric ClientName
Given I have logged in as Administrator user
And I have entered
| Field | Value |
| Client Name | ClientName2 |
When I goto Password
Then I should see :
| Client Name |
| ClientName2 |
Scenario: Registration of Client with ClientName containing symbols
Given I have logged in as Administrator user
And I have entered
| Field | Value |
| Client Name | Client#Name |
When I goto Password
Then I should see :
| Error Message |
| Please enter only Alphanumeric characters |
I think it using like this will be easy in step definition
Please let me know can I use error message in table like client Name
Or is it against the specflow rules?
It seems to me that your step is a little too specific for each case. Its not exactly clear what the filed name is meant to mean in your scenario.
you have this step:
Then I should see :
| Client Name |
| ClientName2 |
Which seems to imply that the tile (Client Name) is the field you want to look in and 'ClientName2' is the value you are looking for, and then you have this in the error case:
Then I should see :
| Error Message |
| Please enter only Alphanumeric characters |
Does this imply that there is a field called Error Message? If this is the case then I would set it up like you have done for the Given step and this as your first Then step:
Then I should see :
| Field | Value |
| Client Name | ClientName2 |
And this as your second Then step:
Then I should see :
| Field | Value |
| Error Message | Please enter only Alphanumeric characters |
If this does not represent a filed to look in then I would instead encode the different place to look in the actual step, and have a different step for checking for an error, like this:
Then I should see the client name 'ClientName2'
and
Then I should see the error message 'Please enter only Alphanumeric characters'
and make the implementation of these steps look in the correct elements on the page. This second approach has the advantage that if you decide to change how error messages are displayed (say they are warned on a popup) then you only need to change the implementation of the step which deals with the error message and you don't need to change every single step that uses an error message.
Ideally you would make your steps ignorant of the implementation. This makes the steps much more likely to be reusable.
Related
I am currently working with Postgresql and I am facing a problem.
I have two tables "question" and "question_detail" in which there are codes. In "question_detail" are the codes including subcode so e.g. TB01Q07, TB01Q07a, TB01Q08_SQ002. Now I wanted to use the command LIKE to see if the table "question" also contains these records. But in "question.code" there are only codes without the following underscore. This is a table that was given to me, I find this somehow very stupid.
The problem is that when I search with LIKE the value TB01Q07a is listed twice. This is also understandable to me, since searching for TB01Q07% also returns the value TB01Q07a.
Does anyone know of a way to search only for TB01Q07a without it resulting in TB01Q07% as TB01Q07a?
Command
SELECT qd.code, qd.label, q.type
FROM public.question q,
public.question_detail qd
where CASE
WHEN qd.code = q.code THEN qd.code = q.code
ELSE qd.code like CONCAT(q.code,'%')
END;
question
| code | type |
| ---------|-------- |
| TB01Q07 | comment |
| TB01Q07a | comment |
| TB01Q08 | option |
**question_detail**
```none
| code | label |
| -------------- | ------|
| TB01Q07 | AB01 |
| TB01Q07a | AB02 |
| TB01Q08_SQL002 | AB03 |
I ran the SQL and wanted the TB01Q07a value to appear only once and not be listed twice.
I think I have found a solution with distinct on.
SELECT distinct on (qd.code) q.id_question,qd.code, q.question, q.question_type
FROM public.question q, public.question_detail qd
where qd.code like CONCAT(q.code,'%');
like('TB01Q07%') matches both TB01Q07 and TB01Q07a, so you get two rows for TB01Q07 and one row for TB01Q07a.
You need to be more precise and include the underscore. Also make sure it's escaped, _ means any one character in a like.
There is no need for a case, use or. Avoid using multiple from statements, use an explicit join with an explicit on. This is clearer and gives you more control over the join.
select qd.*, q.*
from public.question q
join public.question_detail qd
on qd.code = q.code OR qd.code like q.code || '\_%'
Demonstration.
Note: this problem doesn't exist if you use foreign keys. Assign unique IDs to question and reference them in question_detail. This is faster, shields you from changes to the question code, and ensures the referred to question exists.
We are using Serenity with Jbehave for out automation stories, and we have recently upgraded our version to Serenity(2.2.1) and jbejave(1.46.0). Jbehave-core updated from 4.1.3 to 4.4. After the update i am facing an issue with examples table. it is forcing to use delimiter for the step table provided which is taken from story Examples.
This worked previously and got expected values into table
Scenario: Verify scenario
Meta:
Given modal should contains the next content:
{transformer=FROM_LANDSCAPE}
| modalTitle | expectedTitle1 |
| modalFooterTitle | expectedFooterTitle |
Examples:
{transformer=FROM_LANDSCAPE}
| expectedTitle1 | this is first expected title |
| expectedFooterTitle | This is expected footer text |
Now i have to use delimiter to get my expected content into table as below
Given product modal should contains the next content:
{transformer=FROM_LANDSCAPE}
| modalTitle | <expectedTitle1> |
| modalFooterTitle | <expectedFooterTitle> |
Examples:
{transformer=FROM_LANDSCAPE}
| expectedTitle1 | this is first expected title |
| expectedFooterTitle | This is expected footer text |
Also tried with configuration steps like ParameterControls().useDelimiterNamedParameters(false) but didn't worked. We have already implemented thousands of stories and it is hard to replace storied with delimiters. is there any work around to solve my problem?
In the Selenium IDE Firefox add-on I'm trying to create an If statement that will execute a one way if my variable contains a certain text and will execute another way if it contains other text. The issue I'm having is I need it to check just one or two words in a long text so I can't use ==. What I've been trying to do is:
Command | Target | Value
Store Value | id = stuff | Test
If | ${Test}.contains('text') |
But this hasn't been working. Any help with this is greatly appreciated!
I use this contraction for such cases.
Command | Target | Value
Store Value | id = stuff | Test
execute script | var t = ${Test}; return t.contains('text'); | tmp
If | ${tmp}=='true' |
I would like checkmarks to appear in table cells in my github README.md file. The problem is, instead of :white_check_mark: taking the form of a white checkmark, it instead leaves that raw literal text within the table.
Here is the full markdown of the table
| Property | Type | Null | Description |
| -------- | ---- | ---- | ----------- |
| subject | string | | Message subject |
| body_excerpt | string | | Short excerpt of the message body |
| to | list | :white_check_mark: | Names and emails of the message recipients |
| cc | list | :white_check_mark: | Names and emails of the message recipients who were CC'd |
Any ideas why this icon might not be appearing?
Thanks
EDIT: above example actually does show the white check marks. For better reference, check out README.md in this repo
TL;DR
Your table is correctly formatted. The problem is elsewhere.
More detailed answer
Hmmm. I've sent a Pull Request to your repo which "fixes" the rendering of the checkmark. However, the fix is completely unrelated. I just dropped some json from the README.
The removed portion of json seems innocuous though. I'd guess this might not be related to your README content, but rather to the rendering engine GitHub relies on.
I'd strongly suggest you to report this weird behavior to support#github.com (maybe linking to the PR which demonstrates the potential rendering issue).
What's the best way to translate the database content of a zend application ?
I am thinking to add field to database tables
Or create others tables
What I do is to have two tables and a view.
Let's say we have "nouns". So, I create a table NOUN_R with only "IdLanguage" (and whatever needed), another table NOUN_TR (translation), with, "IdLanguage" , a Locale (EN, DE, ...), description and text.
So far:
NOUN_R
NOUN | IDlanguage
Yellow | 1
Red | 2
NOUN_TR
NOUN | IDlanguage | Language
Yellow | 1 | EN
Giallo | 1 | IT
Red | 2 | EN
Rosso | 2 | IT
Finally, you get a view which filters on Locale!
That's the way I'm using right now, not the "best solution" :)