FitNesse: Test that an element is not in a list? - testing

I'm using FitSharp to test an application and have a question related to testing contents of lists. Testing that an element is present in a list is simple to do using, for example, a SubsetFixture and could be written as this:
| Check that element is in list |
| 5 |
But is there a way to write a fixture that tests if an element is not in a list?
| Check that element is not in list |
| 5 |
I want the last table to pass only if 5 is not in the processed list.

The closest you can come with any kind of list fixture would be to use a array or set fixture and to list ALL of the items you DO expect. There is no "not one of these" list fixtures.
I would recommend you just do a do fixture in one like like:
|check|that element | 5 | is in the list | False |
or you could use a column fixture to get the feel for a set fixture
| Check that element is not in list |
| element | exists? |
| 5 | false |

Related

Can i pass variable from Example section into table in behave scenario?

Can i do something like this:
Response contains requested data
| method | status | url |
| post | 200 | <url_variable>|
Examples:
|url_variable|
| test1 |
|test2 |
Its a simple example just to show what i want. Is it possible in behave anyhow?
Basically i should have just tried what i suggested) it is literally like that, write variable name inside a table in <> quotes. And behave will understand it.

How can I verify the options present in list of drop down using the Selenium IDE?

How can I verify the options present in list of drop down using the Selenium IDE?
For example A website has a drop down containing the following options:
Regular
Premium
Annual
Monthly
So I want to verify that the drop down contains following options list using Selenium IDE.
Here example of code that shows how I check lists. xpath_to_elements_of_drop_down_list and should be replaced with corresponding xpath.
execute script | return ['Regular', 'Premium', 'Annual', 'Monthly'] | tabArr
store | 4 | nTabArr
store | 0 | j
store xpath count | xpath=xpath_to_elements_of_drop_down_list | n
assert | ${n} == ${N} | true
echo | Number of elements in the drop down list is correct |
while | ${j} < ${nTabArr} |
execute script | return ${tabArr}[${j}] | tabName
assert element present | xpath=path_to_elements_of_drop_down_list[contains(.,'${tabName}')] |
echo | ${tabName} is present in the drop down list|
execute script | return Number(${j}) + 1 | j
end | |

Cucumber, examples: How can I verify that the value is exact the same as that of in the adjacent column

On the website there are 2 columns...
In my testcase in Selenium, in the examples the values are:
Examples:
| userrol | information 1 | information 2 |
| role 1 | test | rest |
| role 2 | test2 | rest2 |
Now I can test if those values are presented on the website.
but how can I verify that rest2 is the neighbour of test2 ?
and not like this on the website:
| USER | information1 | information2 |
| role 1 | test | rest2 |
| role 2 | test2 | rest |
(It should not only test if it is presented, it should also test that the text in the column next to it is corresponding)
You have to have a containing element in your html so that you can test that test is next to test2 e.g. with
div#row
span#info1 test
span#info2 rest
You could write something with capybara like
expect(page).to have_css('#row info1', text: 'test')
expect(page).to have_css('#row info2', text: 'rest')
If you haven't got another identifiers, css classes or html in your source to do this that simply, you can either modify your source, or use more complex css/xpath queries (google 'css siblings')

Using the database index of choices in vb.net comboboxes

I have a question concerning indexing of choices in vb.net comboboxes.
Here is the scenario:
I have a database-table which is basically of the following structure:
| ID | Product | Property | .....
---------------------------------------
| 0 | Fork | Property A |
| 1 | Spoon | Property B |
| 2 | Knife | Proberty A |
| 3 | Chair | Property C |
| 4 | Candle | Property B |
| 5 | Plate | Property C |
and so on. I use the column "product" to fill a combobox in a vb.net application. Depending on some other choices, the user makes in advance, only products which have a certain property shall be shown in the combobox. I realized that wich my sql-query and then i assign "Product" to the combobox. So far this works (i hided all the sqlite-stuff here):
CB.DataSource = sqlite.SelectData("Select ID, Product from table where Property = "Property A" order by ID")
CB.ValueMember = "Product"
My Problem is now: How to store the selected value. I want to store the ID of the selected product in another table together with some other tings.
If i read the ID of the selected object using
id = CB.SelectedIndex
i get of course just the position in the combobox of that object, not the real database id. These numbers are the same when the property-filter is off but of course different, when it is on. Is there any simple straight forward way to read the corresponding database id out of the combobox or do i have to query for it before storing the value (that would be nasty altough possible as "Product" has the "unique" flag.)
Thank you very much in advance.
Luke

Behat: How do you use multiline values in tables?

How do you use multiline values in tables?
Pystring dont work
| single | multi
| qewr | """
qewrqewr
qwerqre
"""
This doesnt either
| single | multi
| qewr | qewrqewr
| qwerqre
I want to use a scenario outline and seed a form with input multiple times, not having multilines would be a bugger.
You can use "," in your tables. For example:
| single | multi |
| one | one, two |
If you use TableNode extension, check your extension Gherkin.
It possible need upgrade.
https://github.com/Behat/Behat/issues/99
I hope that was helpful, though a bit late.