Forum Discussion
Are you getting any error messages? Or is it simply clicking in the wrong place on screen?
One observation... you're x and y value calculations at the end, you're dividing by 2... so, that means the potential is there to be a "half" a pixel. There's no such thing. So, perhaps, you need to round x and y to the nearest integer value. I don't know if that's the problem itself but it is something I would do to have more "correct" code.
I have gotten two types of error messages.
Case 1. If I have high pixel tolerance value
It finds a wrong place and clicks it, this causes an error because after that it tries to look for a pop-up window that should open after clicking the camera. But of course the pop up doesn't exist, because the test has not actually clicked on the camera.
Case 2. I have low pixel tolerance value
No match is found and I got an error saying that None object does not have attribute Left. This is also quite obvious since location is then "None" and it does not have the attribute.
In regards, to your integer rounding suggestion, that's a good point. I hadn't thought about that. However, at least on my own Python version, integer division is rounded to the lower number automatically. For example 7 / 2 results in 3.
- tristaanogre9 years agoEsteemed Contributor
Just to help with debugging... have you tried doing a simple recording of clicking on a camera image to see what co-ordinates are used there?
Also, in your first case, what co-ordinates are used for x and y? How far off is the click versus any of the camera icons?
Where my brain is going with this (and this is just me thinking out loud, really), is that the co-ordinates returned by the Find Picture call may be correct with regards to the captured picture... but the grid component itself may have a different resolution or configuration. So, while the pixel location on the image may find a camera correctly at pixel (25,100) (as an example), the grid resolution may have (25,100) at a completely different location. Does that make sense?- Teemu9 years agoNew Contributor
That doesn't seem to be the issue. I tried changing the way the screenshot of the screen is taken.
Before:Sys.Desktop.ActiveWindow().Picture(
Now:
livi_TLoik_Ui_Karttatyokalu.HwndSource_Shell.Shell.Grid.ContentControl.MainView.MainGrid.MainPanel.MapPanel.ChromiumWebBrowser.Picture()
I did this because I tried recording a script where I manually clicked the nearest camera icon and the script was like below and so now they should at least be using a similar grid and coordinates.
livi_TLoik_Ui_Karttatyokalu.HwndSource_Shell.Shell.Grid.ContentControl.MainView.MainGrid.MainPanel.MapPanel.ChromiumWebBrowser.Click(973, 24)
If my test finds something to click, and I've gotten co-ordinates (9, 5) and (392, 5) so it's quite far off. The (9,5) thing is probably about finding the first possible match or so. And the (392, 5) could be the first urban area it finds as it has a bit similar color than the camera icon.
I'll try some more values for color and pixel tolerance to see if I could find good ones. Is there some easy way to see the image TestComplete thinks was the right one?I tried Sikuli as well and it managed to find the icon just fine. Its approach is looking for the whole area and returning the one with the best match. Is there a way I could do that in TestComplete? I just recently started using TestComplete so I'm not really aware of all the features :)
- tristaanogre9 years agoEsteemed Contributor
If you turn on the visualizer for your project for playback, whenever a click event occurs, TestComplete will take a screenshot showing where the click happens.
I'm still not 100% convinced that there's not a resolution difference between the Grid component and the picture you're capturing but perhaps with the visualizer in place, we can see a bit more about what is being returned by TestComplete.
Related Content
- 6 years ago
- 2 years ago
- 12 years ago
Recent Discussions
- 11 hours ago
- 7 days ago
- 10 days ago