Evaluate "Cancel" from inputbox in Lazarus - lazarus

using inputbox in Lazarus/Free Pascal gives you a dialogue with "OK" and "Cancel".
Does pressing "cancel" do anything else then returning the default string (which would be the same if I press ok without entering anything in the input field)? Apparently It does so using Delphi! The doc for inputbox is down at the moment, so it's not possible to check there. Thanks!

InputBox() only returns a string. This string is the one edited and confirmed by the user, or the default passed as argument.
Companion to InputBox() is InputQuery(), which returns true or false depending whether the user confirmed or not. The actual string to show and confirm is passed as a var parameter, and is hence returned back.

Related

Check if an element with varying text casing is displayed in Appium and perform logic accordingly

I'm using Appium with the Cucumber Framework and utilizing the Ruby language.
My scenario is my app has multiple buttons that I want to call with a single Gherkin statement "I press the "*" button" where * is modular. I use it for Save, Back, Cancel, Expand, Yes, No, etc buttons with simple text. Here's an example:
And I press the "Create a Note" FAB button
And I am on the Create a Note Screen
Then I tap Back
>> And I press the "Yes" button
Now currently with my app on android there are multiple versions of the "Back" button and they're not all formatted the same. Some have texts that reads "BACK", some are "Back", and some are "back". I designed a series of if statements to handle this discrepancy until I can get the developers to standardize the text they use for these buttons:
Then(/^I press the "([^"]*)" button$/) do |button_text|
sleep 1
#button_text = button_text
binding.pry
if find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").displayed? == true
find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").click()
else
#button_text.capitalize()
if find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").displayed? == true
find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").click()
else
#button_text.upcase()
if find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").displayed? == true
find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").click()
else
#button_text.downcase()
if find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").displayed? == true
find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").click()
else
fail("Could not find a permutation of that button")
end
end
end
end
sleep 2
end
My thinking is that I'll save the button_text argument to a variable, #button_text, and then use the .displayed? method to check if that version of the button is available. If it is I pass the .click() method, and if it isn't I alter the text of the variable via the .capitalize, .upcase, and .downcase methods. I'm sure that using nested if statements isn't the most ideal way to do this so I would love some assistance on a better way to write that statement.
The issues I receive is I get "An element could not be located using the given search parameters" error whenever I get to this line of code. It seems like the .displayed? method doesn't return a value and triggers appium to stop the test.
I want appium to check if that version of the button is present, then adjust the variable and check the new version for upcase, downcase, and capitalize. Any and all assistance would be greatly appreciated.
When you're finding the elements, try setting their text to all uppercase, and then checking for one version of the word that you're searching for.
I.e. BacK or back or BACK would all become "BACK"

ReactiveCocoa - observing isFirstResponder property and UITextField with clearsOnBeginEditing set to YES

I am new to ReactiveCocoa, but I think it's very nice and outstanding technique for reducing code complexity. I just started experiencing with the framework, and not everything is clear for me at the moment, so excuse me if my problem can be solved in some obvious way.
In my app I have login view controller with simple form contains two text fields (username and password) and a button. I would like the button to be disabled if any of two text fields is empty. So, I wrote this code:
RAC(self.loginButton, enabled) =
[RACSignal combineLatest:#[self.userTextField.rac_textSignal,
self.passwordTextField.rac_textSignal]
reduce:^(NSString *username,
NSString *password) {
BOOL valid = (username.length > 0 && password.length > 0);
return #(valid);
}];
It's very simple and it's working. The problem is that one of my text fields (the password field) has secureTextEntry and clearsOnBeginEditing properties set to YES. I will try to explain unwanted behavior that I am experiencing with this configuration:
Let's assume that both username and password fields are NOT empty. In this case the button is enabled. When user taps on password field, it becomes first responder (keyboard appears and user can enter his password), but because of clearsOnBeginEditing being set to YES for that field, the previously entered password is cleared from the text field. That's way password field is now empty. The problem is that signal is not being sent, so the button remains enabled, despite the password field is empty.
My first idea to solve this issue (well, more like workaround solution) was to observe isFirstResponder property on password field beside observing text changes. That's way the block that checks if button should be enabled would be called when password field becomes first responder. I don't know if this solution works, because I have no idea how to implement it using ReactiveCocoa. I have looking for creating a signal for isFirstResponder property changes, but without a luck. It might be not the best approach in order to solve this issue, but nothing comes to my mind at this point.
Then, the question is: how to observe isFirstResponder property with ReactiveCocoa?
And more general question: how to observe text field's text changes when clearsOnBeginEditing is set to YES?
UPDATE:
I found out that I can create signal for UIControlEventEditingDidBegin event that should give me substitution of observing isFirstResponder property changes:
[self.passwordTextField rac_signalForControlEvents:UIControlEventEditingDidBegin]
Unfortunately this does not solve the issue. Now I understand that field is cleared AFTER it becomes first responder, and clearing field automatically after it becomes first responder does not send signal for text changes. That's way when validation block is executed it still thinks that password field is not empty, and the button remains enabled despite password field was cleared and it's empty.
Unfortunately the -rac_textSignal only listens for UIControlEventEditingChanged. If UIControlEventEditingDidBegin were added, you'd be all set.
I suppose you could patch this into it and submit a pull request?
- (RACSignal *)rac_textSignal {
#weakify(self);
return [[[[[RACSignal
defer:^{
#strongify(self);
return [RACSignal return:self];
}]
concat:[self rac_signalForControlEvents:UIControlEventEditingChanged|UIControlEventEditingDidBegin]]
map:^(UITextField *x) {
return x.text;
}]
takeUntil:self.rac_willDeallocSignal]
setNameWithFormat:#"%# -rac_textSignal", [self rac_description]];
}

selenium.chooseOkOnNextConfirmation() is not working

I'm stuck in one of the confirmation message. Below is the code.
boolean bFlag = selenium.isConfirmationPresent(); // which gives bFlag= false
selenium.chooseOkOnNextConfirmation();
selenium.click("//input[#value='Approve']");
// On clicking Approve button confirmation messasge is displayed.
boolean Flag = selenium.isConfirmationPresent(); // Which gives flag= true
Selenium is unable to click OK in the confirmation. I'm unable to continue with further coding. Nun of the selenium commands is working after clicking on approve button.
Can any one help me on this
Regards
I only have a reference to a rather old piece of documentation, but I guess what is said there is still true
http://release.seleniumhq.org/selenium-core/1.0.1/reference.html#chooseOkOnNextConfirmation
every time a confirmation comes up, you must consume it with a corresponding getConfirmation, or else the next selenium operation will fail.
So your code should look like this:
selenium.chooseOkOnNextConfirmation();
selenium.click("//input[#value='Approve']");
String confirmation = selenium.getConfirmation();
assertEquals("expected text of confirmation", confirmation); // check content of confirmation, optional
// now continue with more selenium commands

No action sent when NSSearchField is emptied?

I've set up an NSSearchField in a toolbar and connected an action in Interface Builder. This action gets called every time I enter some text, but not when I click the small cross to empty it or I somehow delete the text I just entered. Is this a bug or is it fixable?
Well, I figured out it actually works. My problem was that 1) I used the search string from the search field to filter some strings and searching a string for an empty string (#"") apparently returns no result 2) when I tried to log the search string using NSLog(#"%#",searchString) I got some output only with a non-empty string, while NSLog(#"sometexthere %#",searchString) seems to work!

in QTP, how to check whether a dialog is already open?

I have been using the following code to check whether a dialog is already open
If Window(window_name).Dialog(dialog_name).Exist = False
Then '' //here qtp waits..
Window(window_name).WinMenu("Menu").Select menu_name
End If
This code is to avoid reopening the same dialog during each run of the code. But the qtp run waits about 10 - 15 seconds & then goes to next step. in what way we can avoid this?
If the dialog is not open, then the menu will be clicked to open the dialog.
The Exist property accepts a value of how long to wait for the object to exist.
If Window(window_name).Dialog(dialog_name).Exist(60) = False
The method mentioned is good. You can also try this method.
If (Window(window_name).Dialog(dialog_name)
.winbutton(Btn_name).Getroproperty("abs_x"))
This returns true if the object exists if not it returns false.

Resources