I'm running into a bit of a problem, but I feel so close to solving it. I have a text file with Usernames and Passwords separated with a pipe:
;info.txt
user1|pass1
user2|pass2
user3|pass3
user4|pass4
user5|pass5
user6|pass6
user7|pass7
user8|pass8
user9|pass9
user10|pass10
and here's the code:
Gui, -SysMenu
Gui, Add, Button, , Log in
getUsers()
Gui, Add, Button, , Exit
Gui, Show
Return
getUsers()
{
userList := ""
loop
{
FileReadLine, line, info.txt, %A_Index%
if ErrorLevel
Break
getUsers := StrSplit(line, "|")
userList .= getUsers[1] "|"
}
Gui, Add, ListBox, h100 vChoice, %userList%
}
ButtonLogin:
MsgBox, You chose %Choice%.
Gui, Submit, NoHide
Return
ButtonExit:
ExitApp
Return
I used StrSplit() to separate the User from Pass and then delimit the Users to get them into proper format for the ListBox. Everything loads just fine, but when I select one from the list and hit "Log in," the first one doesn't give me any result then the correct results are delayed by one. Example:
Click user1 > You chose .
Click user5 > you chose user1.
Click user3 > you chose user5.
Also, if anyone has a better way of doing this, please let me know.
Ah, I figured it out. It was a problem with:
ButtonLogin:
MsgBox, You chose %Choice%.
Gui, Submit, NoHide
Return
The MsgBox was happening BEFORE Submit was going through. Fixed:
ButtonLogin:
Gui, Submit, NoHide
MsgBox, You chose %Choice%.
Return
Related
I am new to Capybara and am trying to write a test where the default option in a dropdown list will change depending on the link the user clicks on in the preceding page. e.g. click on link1, then link1 will be the default option.
I found online someone said to test for the disabled option in a dropdown with the following, but I still can't get it to work.
Then /^"([^"]*)" should be selected for "([^"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
with_scope(selector) do
field_labeled(field).find(:xpath, ".//option[#selected = 'selected'][text() = '#{value}']").should be_present
end
end
Based on your description I'm assuming you mean the selected option rather than the disabled option. To do that in Capybara would be
expect(page).to have_select('id, name, placeholder or label text of select', selected: 'text of selected option')
Using that in your cucumber step with the possibility of scoping would then become
Then /^"([^"]*)" should be selected for "([^"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
within(selector) do
expect(page).to have_select(field, selected: value)
end
end
which you would call something like.
Then "California" should be selected for "State" within "#user_profile"
If you did really want to check for a disabled option in a select you could do it like
select = find(:select, 'id, name, placeholder or label text of select')
expect(select).to have_selector(:option, 'text of disabled option', disabled: true)
If you want to test if you have the option disabled.
Find the number of elements that disable that area. With the command
"size".
If the result is 1 or 0, you can type this command.
Example:
And(/^All segments in this area need to be subject to the product (\d+) see it$/) do
area=find_by_id('temelGostergeler')
number=area.all("div#urunTab.caption[style='display: none;']").size
print "All of "
expect(number).to eq 0
if
number==1
number="No product"
else
number="There are product"
end
p number
end
You can synchronize with the expect command if you want.
I need to create a button in Lotus Notes mail stationary which will insert a text and then the button is deleted from the message.
In the button I have:
res := #Prompt([OkCancelList]; "Is it OK?"; "Select result"; " ";"OK":"Failed":"");
#If(res ="OK";
#Command([EditGotoField]; "Body") + #Command([EditInsertText]; "Everything is fine);
#Command([EditGotoField]; "Body") + #Command([EditInsertText]; "Not so good mate"));
This part works fine, but I am not sure how to delete the button after click. Usually works #Command([EditClear]) but not in this case when I use #Command([EditGoToField]) in the formula.
I suppose i need to use GoToField again with the correct button identifier and then run EditClear, but I do not know where to find it, or if there is another way to do it... Ideas?
Thank you.
Assuming you have the button in field Body and nothing else that have to remain
then change your code to:
#Command([EditGotoField]; "Body");
#Command([EditSelectAll]);
res := #Prompt([OkCancelList]; "Is it OK?"; "Select result"; " ";"OK":"Failed":"");
#If(res ="OK";
#Command([EditInsertText]; "Everything is fine");
#Command([EditInsertText]; "Not so good mate"));
It selects the content of Body (including button) and replaces it by the new text.
Assuming your document is (or could be put into) edit mode, you could still have the button, but have the button in it's own paragraph (or table cell) with a hide-when formula of of MySpecialButtonPressed!="", and then include the line
FIELD MySpecialButtonPressed := #Now;
in the button code.
(Edit: changed test from =1 to !="", then changed the set value from 1 to #Now because Notes doesn't store Boolean values. Unless you're sending out millions of these, the cost of using dates instead of numbers less than the benefit of having more specific information in case you need it.)
I have an xpage with a data view control, that has show checkbox and show header checkbox enabled. I want to be able to provide confirmation with a count of selected documents to the user when they click the submit button.
Example
"Are you sure you want to submit x number of documents?"
My confirm action returns 0 regardless of how many documents I select. What am I doing wrong?
<xp:confirm>
<xp:this.message><![CDATA[#{javascript:var dataView1:com.ibm.xsp.extlib.component.data.UIDataView = getComponent("dataView1");
var val = dataView1.getSelectedIds();
var len = val.length;
return "Are you sure you want to submit " + len + " number of documents?";
}]]></xp:this.message>
</xp:confirm>
The immediate problem that you're running into is that the confirmation message is most likely being computed as the button is rendered the first time - which is to say, when no documents are checked.
Even beyond that, though, the getSelectedIds method is tricky: the selected documents are cleared after each request, so something that would do a request to the server to get the selected ID count would also have the side effect of clearing out the selections.
What may be the way to do here is to do the check client-side with something like this:
<xp:eventHandler ...>
<!-- other action stuff here -->
<xp:this.script><![CDATA[
var count = dojo.query("tbody input[type='checkbox']:checked", dojo.byId("#{id:yourDataViewId}")).length;
return XSP.confirm("Are you sure you want to submit " + count + " document" + (count == 1 ? "" : "s") + "?");
]]></xp:this.script>
</xp:eventHandler>
The Dojo query in there will search for all checked checkboxes inside the body part of the data view (to exclude the header checkbox), restricted to within the specific data view you want to search for. The XSP.confirm client-side method is the same idea as the <xp:confirm/> simple action, and returning the value from it will cancel the submit if the user says no.
I would like to create a button to search my mail's Inbox view for emails which contain a unique string found in the subject field of the selected document. For this, I have created the following button formula. This correctly retrieves the unique string but the search itself does not work.
SearchStringLeftPart := #Left( Subject; "] [");
SearchString := #RightBack( SearchStringLeftPart; "[");
#SetViewInfo([SetViewFilter];SearchString;Subject;0;0)
Please can someone advise if #SetViewInfo can be used for this purpose & if so what is wrong with the formula. Otherwise how else can I achieve the task using a button formula?
Unfortunately, you can't accomplish that with #SetViewInfo.
But, in combination with a short agent you can show only those documents in view which have current document's unique Subject substring in their Subject field.
Create a formula agent "SelectSubjectSearch" with
target "All documents in view"
option "Selects documents in view"
formula
SELECT #Contains(#LowerCase(Subject); #LowerCase(#Environment("SubjectSearch")))
Create a formula button which
writes the search string into environment variable "SubjectSearch"
selects the option "View / Show / Selected Only" in menu
calls the agent "SelectSubjectSearch"
Button code:
SearchStringLeftPart := #Left( Subject; "] [");
SearchString := #RightBack( SearchStringLeftPart; "[");
#SetEnvironment("SubjectSearch"; SearchString);
#Command([ViewShowOnlySelected]);
#Command([ViewShowOnlyUnread]);
#Command([ViewShowOnlyUnread]);
#Command([ViewShowOnlySelected]);
#Command([RunAgent]; "SelectSubjectSearch")
The tricky part is the "View / Show / Selected Only" selection. As [ViewShowOnlySelected] just toggles between "Select Only" and not "Select Only" and you don't know which status currently is set we have to call a double [ViewShowOnlyUnread] which resets [ViewShowOnlySelected] to not "Select Only". The first [ViewShowOnlySelected] sets the information bar to "You are seeing: the item you selected" and the second [ViewShowOnlySelected] does set for sure "Select Only".
Is the subject exposed in the first (sorted) column of the view?
IIRC, SetViewInfo only filter the view on the first column, which alse must be sorted.
Update: Did not refresh the page after I got back from lunch, so did not see that there already was a correct answer.
Create a search view with first column sorted by subject and use view.getAllDocumentsByKey(...)to get the documenta you search
I have One Window application by Which User Can Print Their Product Barcode Value And Also Can Scan it,
Now i am searching for some threading or some other way,
If user Enter 5 value for Print after Printing First value, Function wait for user input in text box (i call textbox up event for capturing scanning value)
and if value is correct so, my function continue its execution or wait until user Scan Proper barcode,
so how can i make method or function which can wait for user input and then continue executions.
private void myFunction1()
{
for (i = 0; i < intPrintNo; i++) // Number Of Print
{
// here I write Code For Print My Barcode
// Now I want to wait For user Input in my text box
jumphere :
txtBarcode.Text = "";
txtBarcode.Enabled = true;
txtBarcode.Visible = true;
txtBarcode.Focus();
if (keyUp()== false)
{
txtBarcode.Text = "";
txtBarcode.Enabled = true;
goto jumphere;
}
// If return True than for loop Continue for next Printing
}
}
From what i've understood from your question, you want to print the barcode of value specified by the user and then user can scan the same to verify if printed properly or not.
You can achieve this functionality in Windows forms using following steps
User enters the value (to print barcode) in txtInput
Presses print button (btnPrint)
The print button event handler will first disable itself and the input textbox (btnPrint.Enabled = txtInput.Enabled = false; Application.DoEvents();) and then print the barcode and set focus on textbox txtVerify.
User will scan the barcode in textbox txtVerify.
User will click on verify button (btnVerify) which will compare the value in txtInput and txtVerify.
If everything fine, clear the txtInput, txtVerify, enable txtInput and btnPrint, set focus to txtInput for next value
If error, do the needful.
EDIT: As per OPs comment (minimum user effort)
You can change the setting of barcode scanner to suffix newline (Enter) after every scan (you can find how to do this setting in the manual provided with the barcode)...... so now,
step 4. User will scan the barcode in textbox txtVerify (the scanning will provide Enter press at the end of scan). txtVerify.TextChanged event handler will check if key pressed in Enter, if so, call the code to verify (compare the values in txtInput and txtVerify)
step 5. Remove this step from above
step 6. If everything fine, clear the txtInput, txtVerify, enable txtInput and btnPrint, set focus to txtInput for next value
step 7. If error, do the needful.
Also, you can modify the first textbox to print the barcode when user presses enter key (so, no need to click on Print button)
So, after above modifications, the user will enter the text press enter (this will print barcode) then scan (as focus is already in txtVerify). If everything is fine, new value can be entered.
To reset the screen, you can provide a 'Reset' button.
Glad to help! Please remember to accept the answer if you found it helpful.