I am able to use WindowsAccessBridge.dll to get access to java window (SwingSet2), and use the dll methods to interact with the controls.
I can iterate the tree (of java controls) using code shown here, and get information from the controls,
and I can do actions like SetText in Text box, or send click action to a button etc.
However, I am finding that the accessibility contexts are not consistent:
The SetText method works perfectly when I use the accessibility context got from the 'setMousePressedFP' method of the dll, after clicking on the text box.
However, I cant use the accessibility context got by iterating the control tree when trying to set text in a text box, although I verified that the other information e.g. size and other properties of the text box is same.
From this doc:
"The functions GetAccessibleContextAt and
GetAccessibleContextWithFocus retrieve an AccessibleContext object,
which is a magic cookie (really a Java Object reference) to an
Accessible object and a JVM cookie. "
However, the accessibility context differs everytime I click on the text box (without restarting the java program). The vmID matches eveytime.
If the AccessibleContext is really a Java Object reference, shouldnt I get the same AccessibleContext number everytime I click on the same control (without restarting the java window) ? and shouldnt that AccessibleContext number also be available in the tree?
Worst part is that the settext method doesnt work when I use the AccessibleContext got from iterating the control tree.
Edit to clarify the question further:
I am clicking on the same text box, so I would expect the windowsaccessdll function to return reference to the same control. As a long value the accessibeContext is different everytime I click, but its ok as the SetText method works everytime with the different long values and I can see the new text set in the text box.
The problem is when I iterate the control tree and the accessibility context got from the tree iteration doesnt work for the SetText method.
More specifically - how does the AccessibleContext compare to a c pointer - the c pointer would always be same when I get it for a specific control. The AccessibleContext appears to be a 8 digit long value that is different by few tens or hundreds based on where the mouse is clicked inside the text box.
Thanks in Advance.
Related
I'm new to Appium and automation in general.
I'm trying to write a login test. I have six separate LinearLayout elements and in each of them I need to insert the value "1". I can identify the element (e.g. the element with the id "container_zero"), but I cannot send the value to it neither with the sendKeys() nor with the setValue() method.
Also, I tried just to type the required digits using the keyboard below (see the screenshots). But as this is a custom keyboard of the app (not a native Android keyboard), I cannot interact with it. I tried the method driver.pressKey(new KeyEvent()) with AndroidKey.NUMPAD_0 and AndroidKey.DIGIT_0 parameters - didn't work. Keyboard has none elements inside on which I could click (it's just a single element with the android.view.View class).
I also have an idea to press the required digit on the custom keyboard using the coordinates (X,Y), but I don't think that this is a good way out (maybe when I launch the test on different devices, the coordinates will be different - correct me if I'm wrong).
Please advice what can I do? I thought about using Espresso at this point, but we have the same app on iOS, so for now I think I would try to stick to the Appium for a little while longer due to its cross-platform feature.
but I cannot send the value to it neither with the sendKeys() nor with the setValue() method. - that is correct, you can see attributes of the element and it is not checkable, clickable, focusable etc. So that means that you are not able to sendKeys() or even click() on it.
Also, I tried just to type the required digits using the keyboard below (see the screenshots)... - that is the correct behaviour (related to your particular example) too, because there are no different elements of the buttons, only one FrameLayout for the whole keyboard.
I see two scenarios:
You can ask developer to enable button elements so you will be able to click() on it
You can calculate coordinates of these buttons in accordance with screen dimension, for example: 1 button = getWindowSize().getWidth() + 50, getWindowSize().getHeight() / 2;.
This scenario is very unstable because of different devices, but it could work if you find correct dependency between dimension and button positions.
Altogether you either need developer intervention or not so easy calculations for coordinates.
I'm using JavaFX for my application's GUI. I want to implement a validation method for all the textfields inside the sign up window. I want to check them all and than, whether they are true or false, I want to use a mark to show the user what field is incorrect. I also want to be able to show a small message box when I hover the mouse pointer over those marks.
Simple way is to create HBox , put TextField,Label in there ,label will be Bound on the textProperty/ or do it with listener
txtField.textProperty().addListener((v, oldValue, newValue) -> {
//code here if valid, set label visible false, else set label visible true(red image crossed or whatever)
});
, when value changes it will check if that is ACCEPTABLE/FAILED state , for instance empty box.States will be changed on property change , use array of your hboxes to check if they are valid or invalid at the time , you can check this based on visibility of Label or internal boolean state value.
For the hover over part , use Tooltip on label.
If you want to go lazyer way , take a look at controlsfx validation it will take care of graphics for you.And its already embedded in its component.Just create validation process
Good beginner reference might be newboston videos so you understand concept.In javafx you gonna use property binding ,listeners etc often , get familiar with them as you cant avoid it.
https://www.youtube.com/watch?v=s8GomyEOA8w
https://www.youtube.com/watch?v=6Zi2L0kHSx4
Since you've given no code I can't give you answer that involves actual coding, because I've got no way of knowing whether or not what I give you will be viable or conflict etc..
In regards to the validation that depends entirely on how your accessing a username/password to compare it to what the user has entered and with out knowing how you're thinking of doing it I cannot give you a good answer.
There are quite a few options to display your red x, you could draw it internally etc..
But the easiest is probably going to be creating an image and importing it to your project, you can set a label next to your JTextField and have the picture set to that lable. Once the user inputs the username/password if either or both are incorrect you could have a method that would set the label to be visible.
The message box is as simple as a tooltip that you could also place on the label which would tell the user that the information they entered is wrong.
I have a JComboBox which I designed in the Netbeans GUI designer. I have successfully bound the "elements" of the box to an ArrayList<String> so that the box populates properly. However, it currently automatically displays the first element of the list as the selectedItem.
I tried to bind the selectedItem to an int at first, thinking it would just show the item at the indicated index. No go. I got a ginormous exception that I didn't understand.
Then, I noticed that in the "Binding" window, it said the element had to be an Object. So, I bound it to a String, thinking that it would find the element that matched that string and show that element. No dice. Now I'm getting some sort of "PropertyResolutionException". I've even tried to use an Integer object with the same result.
Any ideas would be appreciated.
Absent your sscce, it's hard to say where things have gone awry. For reference, setSelectedItem() works as advertised in this example that selects L&F by name.
I get the dialog for changing the properties of the print job by invoking the PrinterJob's printDialog() method without any parameter. There is a field where the user can change the the number of copies to be printed on the right-bottom of this dialog.
And now I want to disable this field (the spinner). That is only one copy to be printed and the user can't change it.
Are there any ideas for it
I don't think there is any way (or i am not aware of) to modify the native or the cross-platform Java print dialogs (last one might help you a bit). What you could do is maybe display your own dialog (without a spinner field) and under-the-hood do whatever you want (like PrinterJob.setCopies(1)).
More info i found here.
Also, have a look at the Java tutorial on PrinterJobs.
I have a JSF/IceFaces application where there is a screen divided into 3 sections. Search fields, a grid and some details fields below. Currently if I enter some data into the search fields and click on a Search button (!) the grid shows the results and a certain method is called that puts the first result record's details into the backing beans of the details fields below the grid. This shows that there is no problem with the way I put data into the details fields.
However I have a gridclicklistener method as well that would like to change the detail fields according to the selection. After the click the same method gets called with the correct parameters that works well if invoked after the click on the Search button. The data is updated in the backing beans but the changes are not rendered even if I click the refresh button in the browser.
I found that if I click on the search button, the data-updating-method gets called from InvokeApplicationPhase.execute. When I get to this line after the grid click then it is from the ApplyRequestValuesPhase.
Do you have any ideas what could make this difference and how to get this work?
Update:
I can clearly see the updated value in the backing bean but it is not reflected on screen at all, even after F5.
I don't know what is causing your original problem.
With the icefaces push renderer however you could force an update:
http://wiki.icefaces.org/display/ICE/Getting+Started+with+ICEfaces+2#GettingStartedwithICEfaces2-icepush