I'm not quite sure what the issue is with my code, obviously I've gone wrong somewhere. Here's the code;
Then(/^the room selection should be switched to auto assign$/) do
autoassign = #browser.iframe(:id , 'iconsole-plugin-session_iframe__').div(:class , 'col-md-8 column').span(:id , 'selected_room').html
Watir::Wait.for_condition(10 , 2 , "Waiting for room to auto assign") {
autoassign.attribute_value(:id).eql?('Auto Assignment')
}
end
And here's the error;
undefined method `attribute_value' for "<span id=\"selected_room\">Auto Assignment</span>":String (NoMethodError)
autoassign is of type String. Ruby String class has no method named attribute_value.
Try removing .html from the first line so it looks likes this:
autoassign = #browser.iframe(:id , 'iconsole-plugin-session_iframe__').div(:class , 'col-md-8 column').span(:id , 'selected_room')
Watir::Wait.for_condition(10 , 2 , "Waiting for room to auto assign") {
autoassign.attribute_value(:id).eql?('Auto Assignment')
}
Related
I have the following grammer, but I want to do some validation on this. I want to make an error if there are duplicate names in the "players" list.
Grammer:
Football:
'Club' name=STRING playerList=PlayerList
footballObjects+=FootballObject
;
FootballObject:
Player | Coach
;
PlayerList:
players+=[Player] ( players+=[Player] )*
;
Player:
'Player' name=ID
;
I tried the following:
#Check
def checkGreetingStartsWithCapital(Football model) {
val names = newHashSet
for (g : model.playersList.players) {
if(!names.add(g.name))
error("duplicate" , g, FOOTBALLPACKAGE.Literals.FOOTBALL__PLAYERS_LIST)
}
}
But this does not work. Any ideas why?
The easiest is to mark the list entry by calling error not on the referenced player but on the playersList itself and call the error method that takes an index as well. e.g.
error("bad", playersList, MyDslPackage.Literals.PLAYERS_LIST__PLAYERS, index)
I am trying to make an app for vacation requests but i am facing a problem.I have e model called VacationRequest and a view of VacationRequest where the result will be shown.
VacationRequest.rb model
def skip_holidays
count1 = 0
special_days = Date.parse("2017-05-09", "2017-05-12")
special_days.each do |sd|
if ((start_data..end_data) === sd)
numero = (end_data - start_data).to_i
numro1 = numero - sd
else
numero = (end_data - start_data).to_i
end
end
end
VacationRequest show.htm.erb
here i called the method from model
#vacation_request.skip_holidays
this is showing errors and is not working. Please help me with that!
My approach to this would be the following:
def skip_holidays
special_days = ["2017-05-09", "2017-05-12"].map(&:to_date)
accepted_days = []
refused_days = []
(start_data..end_data).each do |requested_date|
accepted_days << requested_date unless special_days.include?(requested_date)
refused_days << requested_date if special_days.include?(requested_date)
end
accepted_day_count = accepted_days.count
refused_days_count = refused_days.count
end
This way you iterated over all requested dates (the range), checked if the date is a special day - If so, refuse it, otherwise accept it.
In the end you can display statistics about accepted and refused dates.
You cannot create a date range by passing multiple argument to the constructor. Instead call the constructor twice to create a range:
special_days = Date.parse("2017-05-09") .. Date.parse("2017-05-12")
Or if instead you want only the two dates, do:
special_days = ["2017-05-09", "2017-05-12"].map &:to_date
This Date.parse("2017-05-09", "2017-05-12") don`t create a range, only return the first params parsed:
#irb
Date.parse("2017-05-09", "2017-05-12")
=> Tue, 09 May 2017
You can do it this way:
initial = Date.parse("2017-05-09")
final = Date.parse("2017-05-12")
((initial)..final).each do |date|
#rules here.
end
I'm still learning PowerBuilder and trying to get familiar with it. I'm receiving the following error when I try to run a program against a specific document in my database:
ct_fetch(): user api layer: internal common library error: The bind of result set item 4 resulted in an overflow. ErrCode: 2.
What does this error mean? What is item 4? This is only when I run this program against a specific document in my database, any other document works fine. Please see code below:
string s_doc_nmbr, s_doc_type, s_pvds_doc_status, s_sql
long l_rtn, l_current_fl, l_apld_fl, l_obj_id
integer l_pvds_obj_id, i_count
IF cbx_1.checked = True THEN
SELECT dsk_obj.obj_usr_num,
dsk_obj.obj_type,
preaward_validation_doc_status.doc_status,
preaward_validation_doc_status.obj_id
INTO :s_doc_nmbr, :s_doc_type, :s_pvds_doc_status, :l_pvds_obj_id
FROM dbo.dsk_obj dsk_obj,
preaward_validation_doc_status
WHERE dsk_obj.obj_id = :gx_l_doc_obj_id
AND preaward_validation_doc_status.obj_id = dsk_obj.obj_id
using SQLCA;
l_rtn = sqlca.uf_sqlerrcheck("w_pdutl095_main", "ue_run_script", TRUE)
IF l_rtn = -1 THEN
RETURN -1
END IF
//check to see if document (via obj_id) exists in the preaward_validation_doc_status table.
SELECT count(*)
into :i_count
FROM preaward_validation_doc_status
where obj_id = :l_pvds_obj_id
USING SQLCA;
IF i_count = 0 THEN
//document doesn't exist
// messagebox("Update Preaward Validation Doc Status", + gx_s_doc_nmbr + ' does not exist in the Preaward Validation Document Status table.', Stopsign!)
//MC - 070815-0030-MC Updating code to insert row into preaward_validation_doc_status if row doesn't already exist
// s_sql = "insert into preaward_validation_doc_status(obj_id, doc_status) values (:gx_l_doc_obj_id, 'SUCCESS') "
INSERT INTO preaward_validation_doc_status(obj_id, doc_status)
VALUES (:gx_l_doc_obj_id, 'SUCCESS')
USING SQLCA;
IF sqlca.sqldbcode <> 0 then
messagebox('SQL ERROR Message',string(sqlca.sqldbcode)+'-'+sqlca.sqlerrtext)
return -1
end if
MessageBox("PreAward Validation ", 'Document number ' + gx_s_doc_nmbr + ' has been inserted and marked as SUCCESS for PreAward Validation.')
return 1
Else
//Update document status in the preaward_validation_doc_status table to SUCCESS
Update preaward_validation_doc_status
Set doc_status = 'SUCCESS'
where obj_id = :l_pvds_obj_id
USING SQLCA;
IF sqlca.sqldbcode <> 0 then
messagebox('SQL ERROR Message',string(sqlca.sqldbcode)+'-'+sqlca.sqlerrtext)
return -1
end if
MessageBox("PreAward Validation ", 'Document number '+ gx_s_doc_nmbr + ' has been marked as SUCCESS for PreAward Validation.')
End IF
update crt_script
set alt_1 = 'Acknowledged' where
ticket_nmbr = :gx_s_ticket_nmbr and
alt_2 = 'Running' and
doc_nmbr = :gx_s_doc_nmbr
USING SQLCA;
Return 1
ElseIF cbx_1.checked = False THEN
messagebox("Update Preaward Validation Doc Status", 'The acknowledgment checkbox must be selected for the script to run successfully. The script will now exit. Please relaunch the script and try again . ', Stopsign!)
Return -1
End IF
Save yourself a ton of headaches and use datawindows... You'd reduce that entire script to about 10 lines of code.
Paul Horan gave you good advice. This would be simple using DataWindows or DataStores. Terry Voth is on the right track for your problem.
In your code, Variable l_pvds_obj_id needs to be the same type as gx_l_doc_obj_id because if you get a result, it will always be equal to it. From the apparent naming scheme it was intended to be long. This is the kind of stuff we look for in peer reviews.
A few other things:
Most of the time you want SQLCode not SQLDbCode but you didn't say what database you're using.
After you UPDATE crt_script you need to check the result.
I don't see COMMIT or ROLLBACK. Autocommit isn't suitable when you need to update multiple tables.
You aren't using most of the values from the first SELECT. Perhaps you've simplified your code for posting or troubleshooting.
It seems that there are already some answers available but I can't find proper answer for my question.
Here is the code:
Private Sub Combo2_click()
Dim item_id, price As Integer
Dim item_name As String
If Combo2.Index Is 0 Then
price = 30
ElseIf Combo2.Index Is 1 Then
price = 40
ElseIf Combo2.Index Is 2 Then
price = 50
ElseIf Combo2.Index Is 3 Then
price = 60
Else
price = 55
End If
End Sub
I am getting error as "Compile Error : Type MisMatch" ... I don't know why! It is showing error on the like Private Sub COmbo2_click() ...
There are two mistakes in your code:
1- You should use Combo2.ListIndex instead of .Index. (because index is used for something else and that's when your control is an element in an array)
2- You should replace Is with = (and that's what throws the exception of Type mismatch).
Hope that helps :)
Cursor cursor = managedQuery(Phone.CONTENT_URI,new String[] { Phone.DISPLAY_NAME, Phone.NUMBER }, Phone.NUMBER + "= ?", new String[]{address},Phone.DISPLAY_NAME+" ASC");
cursor.moveToFirst();
String name=cursor.getString(cursor.getColumnIndex(Phone.DISPLAY_NAME));
the line with the code 'cursor.getColumnIndex(Phone.DISPLAY)' is giving me an error on the phone but not on the emulator.. Can you please tell me can this this happen?? Infact I have used this line in 3 different places.. It works at 2 places and not in 1 place
try this links
http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/