verify certain value does not exists within a dropdown list - cucumber

I wish to verify a certain value does not exist within a drop down list.
So html is:
<select id="delivery" name="delivery" onchange="this.form.submit();">
<option selected="selected" value="Del1">Delivey1</option>
</select>
So I wish to ensure that when I have certain items in my basket delivery option 2 is not present.
So the code I was trying:
result = #browser.select(:id, "delivery").include? ("Delivery2")
assert result = false
However this does not work.
Any suggestions or help would be appreciated!!
Thanks!

Based on your code, I am guessing that result is correct. It looks like the problem is the assertion. Doing the assertion
assert result = false
is not valid syntax (you cannot do an assignment here).
Try one of the following instead:
assert( result == false ) #Note that it is == instead of =
assert_equal( true, result )

Related

Cognos Report Studio: CASE and IF Statements

I'm very new in using Cognos report studio and trying to filter some of the values and replace them into others.
I currently have values that are coming out as blanks and want to replace them as string "Property Claims"
what i'm trying to use in my main query is
CASE WHEN [Portfolio] is null
then 'Property Claims'
ELSE [Portfolio]
which is giving me an error. Also have a different filter i want to put in to replace windscreen flags to a string value rather than a number. For example if the flag is 1 i want to place it as 'Windscreen Claims'.
if [Claim Windscreen Flag] = 1
then ('Windscreen')
Else [Claim Windscreen Flag]
None of this works with the same error....can someone give me a hand?
Your first CASE statement is missing the END. The error message should be pretty clear. But there is a simpler way to do that:
coalesce([Portfolio], 'Property Claims')
The second problem is similar: Your IF...THEN...ELSE statement is missing a bunch of parentheses. But after correcting that you may have problems with incompatible data types. You may need to cast the numbers to strings:
case
when [Claim Windscreen Flag] = 1 then ('Windscreen')
else cast([Claim Windscreen Flag], varchar(50))
end
In future, please include the error messages.
it might be syntax
IS NULL (instead of = null)
NULL is not blank. You might also want = ' '
case might need an else and END at the bottom
referring to a data type as something else can cause errors. For example a numeric like [Sales] = 'Jane Doe'
For example (assuming the result is a string and data item 2 is also a string),
case
when([data item 1] IS NULL)Then('X')
when([data item 1] = ' ')Then('X')
else([data item 2])
end
Also, if you want to show a data item as a different type, you can use CAST

IBM Cognos prompt value when not entered

I have a problem in report studio. please help me to figure this out..
i have a optional prompt, i want to check whether the value is selected or not..
Please help how to check..
if (?parameter? is null ) then ('1') else ('2')
or
if (ParamDisplayValue('parameter') is null ) then ('1') else ('2')
Both the above are not working..
Suppose if i select any value in the prompt then the else part works and i get the result as 2, if i wont select anything then i'm not getting the result as 1
My guess, without doing extensive testing, is that an empty optional prompt doesn't exist at all and can't be compared to null. That said, I believe there's an easy fix.
Since you know that when you select an item '?parameter? is null' will return false, '?parameter? is not null' should return true and you can reverse the logic:
if (?parameter? is not null) then ('2') else ('1')
Try to put a conditional block. Set a block variable of type boolean with this expression:
ParamDisplayValue('myParam') is null
Then go to your conditional block again switch property "current block" to yes/no.
When yes (meaning that our block variable is true so the parameter is null) add a text item and just write "All".
When no add a text item with source type as report expression and write ParamDisplayValue('myParam')
P.S: there is also a way to count how many values the user selected (so as not to display all of them 1 by 1 but just show "62 values selected") but it needs some javascript and a hidden prompt field.
Use ParamCount
More details here:
http://joesanswers.blogspot.com.au/2008/09/checking-for-empty-parameters-in-cognos.html

Jade Template - SELECT OPTION with for

select(id="xxx", name="xxxyyy")
- for(var i = 1;i<10;i++){
option(value="#{i}") Some value for #{i}
- }
but it generates the following HTML
<select id="xxxx" name "xxxyyy"></select>
<option value="1">Some value for 1</option>
....
I've tried to include the select inside the for loop and it works as expected (it generates 10 select drop controls with one item on each one of them).
What am I missing here?
I think you've got your indentation messed up. Jade is like coffeescript, in that indentation is significant and donates nesting. See here. So that the Jade engine knows that your option loop should be within the select tag, the option loop needs to be indented from the select statement, whereas you've got yours level with the select statement.
select(id="xxx", name="xxxyyy")
-for(var i = 1;i<10;i++){
option(value="#{i}") Some value for #{i}
-}

How to check the value of a boolean (set by user) with a variable string?

The user sets a boolean to true or false.
That does (exemple)
ElementNameone = true
ElementNametwo = false
ElementNamethree = true
Etc.
Now I have a string that is loaded from a file. The string called name can have values that are Nameone, Nametwo, Namethree, etc. Anyone of them at a time.
Now I would like to be able to do this
if Element .. name == true then
do something
Except I don't know how to do this properly.
I've tried to do
if not not ("Element" .. name) then
But it does not work.
Can anyone help ?
Thanks
Try this:
if _G["Element" .. name] == true then
-- do something
end
Note that this will work only if the variables set by the user (ElementNameone, .. etc.) are globals.
It's very likely you're solving the wrong problem.
You say "the user" sets these variables. How? An end user normally isn't going to be interacting directly with variables inside your program.
Can you use a table instead, with ElementNameone as the key and true or false as the associated value? If so, that would be a lot cleaner.

Pyramid Chameleon Tal:condition 'Not' issue

I am trying to display conditional text in a Pyramid Chameleon template. Basically, checking if the dictionary key 'maxed_out_alerts' is empty (false) or has a string 'yes' in it.
<p tal:condition="not:maxed_out_alerts"><h3>Maxed Out.</h3></p>
<p tal:condition="maxed_out_alerts"><h3>Not Maxed Out</h3></p>
When 'maxed_out_alerts' is an empty string, 'Maxed Out' is only displayed (correctly). However, If 'maxed_out_alerts' contains 'yes' string both 'Maxed Out' and "Not Maxed Out' are displayed (incorrectly).
It seems that the NOT is always evaluated to a true condition. It should display one or the other messages not both. What am I doing wrong? thanks
For TAL conditionals in python you can say python: and then use a python syntax conditional
<p tal:condition="python:len(maxed_out_alerts) > 0"><h3>Maxed Out.</h3></p>
It could help if you save boolean state in a boolean variable. By storing this information in a string you run into such problems you are facing right now. That's what builtin python types are made for - use them.
As a pyramid developer I would advice to move the logic to evaluate the current value of maxed_out_alerts into a string into a view method and pass the computed string in a dictionary to the renderer/template. This way you can even create tests for the view logic - any pyramid tutorial, simple or advanced shows you how to do that.
A good start for any simple logic - imagine logic gets more complicated or you even have to translate the text for the template.
#view_config(name="yourname", renderer='templates/yourtemplate.pt')
def myview(request):
"""
#get boolean state from model
#could be that you want to have it the other way round
#or do it by using python ternary operator - a if test else b
if model['maxed_out_alerts'] == True:
maxed_out_alerts = 'Maxed Out'
else:
maxed_out_alerts = 'Not Maxed Out'
return dict(maxed_out_alerts = maxed_out_alerts)
In your Template
<h3 tal:content="maxed_out_alerts">text for maxed out alerts</h3>
or
<h3>${maxed_out_alerts}</h3>

Resources