Selenium IDE: If variable contains some text - selenium-ide

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' |

Related

Problem with Postgresql, LIKE gives double results

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.

Failed to convert Jbehave named parameters without delemeters

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?

Using output status of VerifyElementPresent in Selenium IDE on chrom

I am using Seleium IDE on chrome. I want to make a simple code using the output of "VerifyElementPresent" command. If the output is true, execute code1 else execute code2.
I cannot find a way to store the output of this command in a variable so I can use it further.
THanks
There is no information in documentation about storing result of 'verify element present' command. But you can use 'store xpath count' for this reason.
store xpath count | xpath=some_xpath | n
if | ${n} > 0 |
code1...
else | |
code2...
end | |

Display error in | Error message |in Specflow Nunit

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.

How to write custom eclipse formatter for a custom file type (text)

I'd like to write an eclipse formatter for a custom file type (text based). The goal is to format tabular text data like Fitnesse does, for example:
|column1 | column 2 |
|5|6|
When formatted would appear as:
| column1 | column 2 |
| 5 | 6 |
I don't think the code would be hard to write and I may be able to get the algorithm from fitnesse, but I don't know how to write the plugin for eclipse.
Thanks