Dynamix Xpath for bounds in appium - xpath

I want to create a dynamic xpath in appium to get the elements using bounds that has x coordinates 53 and varying y coordinates. This code is giving me error "Could not find function:"
driver.findElements(By.xpath("[(contains(#bounds, '][53,'))]"));

Try using below code it works for me on android
driver.findElement(By.xpath("//android.widget.ImageButton[#bounds='[9,288][144,318]']"));

I managed to get the partial match working.
I'm not sure but perhaps your issue is that you are using "][53," which matches the bottom right corner x position. The code I tested with used the top left corner x and y position.
close_button = driver.find_element(by=AppiumBy.XPATH, value="//android.widget.ImageButton[contains(#bounds, '[78,78][') and #clickable='true']")
Your question actually was the answer I was looking for.

Related

Getting Y co-ordinate of a page in mpdf

I am using mpdf to generate certain tables on a pdf. Each table has a title text on top of it. I want to know the current y coordinate of the page to make the output proper. Currently sometimes the title comes on 1 page and the table on the next
I tried using $mpdf->GetY()
but it gives an error. Please help
Hi i got the solution to my question..used $mpdf->y which returned my y position. So i could check if the y position is greater than the approx height of the table. :)
class mPDF has a public property $y
You can directly get Y co-ordinate by accessing this variable.
Check if that works for you.

Calculate Protractor Angle in WP7

I am trying to create a protractor in windows phone 7 using silverlight framework and I am stuck in getting the protractor needle to rotate.
I am using rotate transform and specifying the angle value to the transform name in the code behind.
I need a perfect angle calculation and currently the protractor needle is not rotating as required.
Any help would be truly appreciated, thanks.
try this:
var rotateTransform = (RotateTransform)yourControl.RenderTransform;
rotateTransform.Angle = 90.0f;
I wrote this out of top of my head, but this is general rule how you should do this in code behind... the other thing is - make sure you are getting some values via Debug.WriteLine() and then watch Output in VS.

Capturing screenshot of windowed OpenGL window in AutoIt?

For my graphics class, I need to match an OpenGL sample output in a pixel-perfect way.
I figured it would be cool if I could spawn the sample, send it some input, then take a screenshot of the exact OpenGL area, do the same for mine, and then just compare those screenshots. I also figured something like AutoIT would be the easiest way to do something like this.
I know that I can use the screencapture function, but I'm unsure of how to get the exact coordinates and size of the OpenGL area of the window (not the title bar/surrounding window stuff).
If anybody could help me out that would be awesome.
Or if anybody can think of an easier solution than AutoIt, and can point me in the right direction, that'd be great too.
EDIT: I also don't have access to the source code of the sample output program.
AutoIt is a pretty good tool for this job. I think you already found the _ScreenCapture in the help file, it has parameters for: X left, Y top, X right and Y bottom coordinates. However, the _ScreenCapture function stores to a file. I've made a library where you can capture part of the screen, or a window, and save this to memory. Then you can get the pixel colors from the memory and compare them to your existing pixels. You can find it here: http://www.autoitscript.com/forum/topic/63318-get-or-read-pixel-from-memory-udf-pixelgetcolor-au3/
The part of a window which does not include the titlebar and the borders is called the 'client area'. You can get the width and the height of the client area with the WinGetClientSize. Alternatively, you can use ControlGetPos on the OpenGL control to get the X and Y relative to the window, and the width and height of the OpenGL control. Combined with WinGetPos you should be able to calculate the values you need for _ScreenCapture. You should be able to find out a good approach if you use the "AutoIt window info" tool.
Finally, a simple and short solution which gives you little control, but might be just what you need, is the PixelChecksum function. Once you have the coordinates of the OpenGL part, you can use PixelChecksum and get a value corresponding to the pixels of the screen (a checksum of the pixels). You can then compare this value to a pre-recorded value to tell whether the pixels on the screen are exactly the same. Check the Autoit help file of PixelChecksum for an example.
If you want to capture data from an OpenGL buffer, here is how you can do it with legacy OpenGL (version 1.2 or so)
glFinish();
glReadBuffer(GL_FRONT);
glPixelStorei(GL_PACK_ALIGNMENT, 4);
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
glPixelStorei(GL_PACK_SKIP_ROWS, 0);
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
glReadPixels(ox, oy, w, h, mode, GL_UNSIGNED_BYTE, img);
where:
ox and oy are origin x and y
w and h are width and height
mode is the mode, like GL_BGR if you want to save to BMP
img is a pointer to unsigned int * to copy the image to
You can search for glReadPixels on the internet and see the reference for more information.

CGPathContainsPoint: And if i scaling up or down ???

question is....
i need to handle tap gesture.
Now, i have a lot of paths builded by CGPath (each path has an ID), and by CGContextAddPath i create and fill my planimetry. Whether i tap on a path, i wish that right ID is shown.
So, i'm using CGPathContainsPoint in touchbegin to do this but, if i scale up or down my planimetry by CGAffineTransform, CGPathContainsPoint method returns wrong information (FALSE) also if i touch on a (scaled) path.
How can i fix it ?!
I tried by adding CGAffineTransform element as second argument of CGPathContainsPoint method but point touched isn't scaled too, so, nothing happens (instead, the same problem with translation is fixed by this same way!).
Here you can find the CODE semplified
Sorry for my english ( i'm italian ) :P
Thx in advance
OK! I found the problem !!!
I have to apply the inverse function!!
If i scale by 10, i have to scale the point by 1 / 10.
For translation if i drag by 10, i have to drag back by -10 (for rotating the same i think).

OpenGL text position under Windows

I am developing an OpenGL application that has two working modes: windowed mode and full screen.
The app displays several graphic objects using OpenGL and writes some text strings using that same API. The program displays the texts strings in its intended positions when running as a windowed application, but when running full screen the text strings are displayed in an upper position that its intended position.
The app creates the fonts using wglUseFontBitmap and displays the text strings with glCallLists (it sets the text position using glRasterPos2i). Before the text is displayed I adjust the text position adding an offset to the Y coord. I get that offset using the GetDCOrgEx Win32 API call.
I think you have to call GetDCOrgEx again after getting in fullscreen mode, or do you already do this? It would help if you could post the code where you call GetDCOrgEx and calculate the Y offset.
EDIT: Another idea: Could it be that you can use the same Y offset, but negative? Or perhaps calculate Y position and then use height-ypos? There's some source code here that uses glRasterPos2i different when in fullScreen:
if(!state->fullScreen)
// if fullScreen (don't forget the image/GL y-coord vertical flip)
glRasterPos2i((w - state->img->cols())/2, (h - state->img->rows())/2);
else
// for non-fullscreen images
glRasterPos2i(0,h);
Schnaader, thanks a lot for your answers.
I have solved the problem modifying how I calculate the offset that I need to add to the Y coord. Now the offset is calculated with the following code:
m_iYOffset = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYBORDER);
The above code solves the problem for my application.
Here's the code to calculate the Y offset:
POINT vOffset;
m_hdc = GetDC(m_hWnd);
if (m_hdc)
{
GetDCOrgEx(m_hdc, &vOffset);
m_iYOffset = vOffset.y;
}
The above code is called once the program has set up full screen mode. I tried to call GetDCOrgEx every time I need to write a text string, but the text is written at the same positions that when GetDCOrgEx is called only once.

Resources