How to get button state in XCUITest?
It is just a NSButton which acts as a toggle button. The images changes upon clicking. In application i check with button.state which returns 0 or 1. depending upon the values i changes the images.
#IBAction func checkBoxClick(sender: NSButton) {
print("Checkbox state ", sender.state)
}
But when writing XCUITest automaton code, i am not able to get the state of the button. there is no attribute like state. Also when i take 'value' or 'selected' attributes of the button it always gives nil and false.
let window = XCUIApplication().windows["Window"]
let button = window.buttons["Button"]
button.click()
print("Button selected ",button.selected)
print("Button selected value ",button.value)
button.click()
print("Button unselected ",button.selected)
print("Button unselected value ",button.value)
Values printed are
Button selected false
Button selected value nil
Button unselected false
Button unselected value nil
Any inputs.
In your application code, you could map the 0/1 state to selected/not selected. Default state should be false and when it is toggled, invert the state of sender.selected.
The selected property represents two states and provides the same functionality as your .state addition.
Related
I have a RecyclerView that I want to add a colored place holder so that when the user clicks on an item, that item and all before become colored. If the previous item clicked was an item after it I'll uncolor that and the other items that come after the current item clicked.
I've gotten it to color any item clicked but I'm not sure how to handle one click affecting other items like that
I had the clicks be represented by a boolean[](true = selected, false = not selected). When a position is selected make that position true and the ones before it true and the ones after it false.
I then call notifydatasetchanged which starts up OnBindViewHolder to set the colors based of if the positions are true or false
I have a strange bug when I use an input field on a sweet alert I can't have the cursor inside my input field here is a jsfiddle.
https://jsfiddle.net/gvzwu5st/
If I include
showConfirmButton: false
Then it works fine here is the fiddle
https://jsfiddle.net/16L4sddt/
When you have showConfirmButton: true, the openModal() function (line 653) gives focus to the confirm button (line 662):
$okButton.focus();
When you try to click in the input field, the handleOnBlur() function (line 396) is called because the confirm button loses the focus. The functions defines the $targetElement variable which refers to the confirm button (line 397). Skipping some lines... the function will loop through each button of the modal to check if it is the element that got the focus. In your case, the target element is the input field, so it is not any of the buttons. The variable btnIndex keeps the value -1. Lines 413-416:
if (btnIndex === -1) {
// Something in the dom, but not a visible button. Focus back on the button.
$targetElement.focus();
}
So the confirm button ($targetElement) is given back the focus, which prevents the input field from ever receiving it.
I have two buttons,if the first button is clicked two textfields will come and the second button dimension will change to next to the textfields.Now if i click the second button one textfield will appear.I did all those things.Now my question is if we click the second button,textfield will appear with what ever the dimensions we have given,but if we click the second button after clicking the first button also dimensions should change.Can any one help to do this.
Thank You
you can add multiple selectors on a single button for different control states
Your question is vaguely phrased. If I understood correctly, when the second button is pressed, you want two different actions done depending on whether the first button has previously been pressed or not. If that's the case, the solution is to define a boolean flag, which will be set to YES when the first button is pressed, and will be set to NO (if needed) after the second button's action is completed.
In your header file:
#interface yourViewController: UIViewController {
BOOL firstButtonFlag;
}
And in yourViewController.m file:
-(void)viewDidLoad {
firstButtonFlag = NO; // technically redundant line, just to show the concept
}
-(IBAction)firstButtonPressed {
firstButtonFlag = YES;
// whatever action you want done
}
-(IBAction)secondButtonPressed {
if (firstButtonFlag) {
// whatever action if first button had been pressed before
firstButtonFlag = NO; // resetting the flag for next round
}
else {
// whatever action if first button had NOT been pressed before
}
}
This is my situation:
a NSMatrix (in radio mode) that contains 4 buttons
An object with properties "top","left","right","bottom" and the relative objectController.
each button has state bind to one of the objectController key (top,left,right,bottom).
Radio mode makes me sure that only one button at once has state = on, my problem is that when i select a button the object property chained to the objcet controller goes to 1, but the previous one selected (now with state = off) doesn't go to 0 (the buttons view works correctly and only 1 button is active at time).
How can i obtain a on/off effect also on the bind object?
Instead of binding each button, you should bind the selectedIndex binding of the NSMatrix itself to a property in your model.
You'll need to change the way you store the selected edge in your code by using a single property:
typedef enum {
TopEdge = 0,
RightEdge,
BottomEdge,
LeftEdge
} Edge;
#property Edge currentEdge;
This will allow you to keep track of the currently selected index.
I dynamically create buttons on a form and use the button text as ids so that I can pass that to an SQL query to pull saved data about that button when necessary, but I also use an image over buttons that have information saved about them. What I need to know is how do I keep the text on the button from appearing when there is an image assigned to that button? By default vb.net shows both the text and the image and no TextImageRelation values allow for the image to take precedence. I tried changing the text color to transparent, but the outline of the text is still visible through the image. Is there anyway to keep the text value as it is but just show the image on the button?
Don't use the .Text property of the button to store your information. Use the .Tag property for your IDs. Just set the .Text property to "" (empty string), that way it won't interfere with your image.
not sure, but why not just set the value to a variable to be passed to the SQL on the button click event and not place the text on the button? If you are using the same button click event for several buttons you could check the sender's ID and then set the variable based on that.
To Enable "Button1" Click (Visible)
Button1.Enable = True
To Disable "Button1" Click (Visible)
Button1.Enable = False
Hide "Button"
Button1.Visible = True
or
Button1.Show()
Show "Button"
Button1.Visible = False
or
Button1.Hide()
You can Also Used the code to any Tools (TextBox, Label, ComboBox, Radio Button, Button, Link, GroupBox)