How to ask appium to drag an element? - appium-android

I am taking the first steps in mobile automation.
I have a view such as below:
As you can see, I have a android.view.ViewGroup which I should drag an element over it.
My question is:
How can drag the button and take it to the right?

You can use the touchAction method :
Just provide the x , y coordinates upto to which you want to drag
new TouchAction(driver)
.press(PointOption.point(256, 1115))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(2000)))
.perform()
.moveTo(PointOption.point(256, 600))
.release()
.perform();
or if you wanna do it more precisely then you can get the device's x ,y width and drag it accordingly.

Related

How to scale an object based off of Text size and length in Unreal?

This maybe an easy question maybe not. Essentially, I am creating a VR application and I am also making a 3D UI system for it. I have the basics of creating a 3D button and clicking it done already. What I want to do now is scale my button in order to fit my custom text inside of it. Is there a way to automatically scale the object based off of the size of another? I'll attach some pictures to maybe describe the problem and what I want to accomplish.
Currently,
What I want to happen in something like the ConstructionScript:
https://api.unrealengine.com/INT/BlueprintAPI/Widget/GetDesiredSize/index.html
Try something like this , you call if from text variable, it return struct with X and Y float , hope it may give u starting point.
Edit :
You can get Text render TextlocalSize or TextworldSize .

How to put buttons on SpriteKit with Swift code?

I tried to make a game on Xcode 7 Beta, I almost finished it but the problem is I don't know how to put buttons with Swift code, I tried to put them on Main.storyboard but they don't arrange very well. some of them become bigger and some smaller etc... So I want to know how to put these buttons with code as in picture below.
Blue button first from the left is Leaderboard, then Facebook share, twitter share, and another default button (maybe it will be Remove Ads)
Your buttons should be .png files in the images.xcassets (you can add a new image set by clicking the + at the bottom). It will automatically choose the right size depending on the device/simulator. Then you create a variable to store your node like this:
let myNode = SKSpriteNode(imageNamed: "yourImage")
Then you can position the node multiple ways but i'll show you what I think will work best for you. Use myNode.position = CGPointMake(CGRectGetMaxX(self.frame) *0.40, CGRectGetMaxY(self.frame) * 0.25) This will get the max x and y values of the screen, multiply them by .4 and .25 respectively and then you can add the node to the scene will this line:
self.addChild(myNode)
Oh, and you can multiply the values by whatever decimal you want to get the nodes in the exact spot. IF you want them to be side by side you can even do something like this: myNode.position = CGPointMake(otherNode.position.x + myNode.frame.size.width/2, CGRectGetMaxY(self.frame) * 0.25)

tkinter listbox drag and drop

I'm trying to make a listbox with the ability to do drag and drop onto a canvas. I've done drag and drop before, but it was only between canvas.create_text loosely based on the code for a this checkers program I found here. I've seen a couple of questions about drag and drop listboxes but they only deal with changing the order of elements in the listbox. What I'm dealing with is a listbox which has a list of names, and a canvas with some create_text objects on the canvas, and I want to be able to drag a name from the listbox onto the canvas. If figure I'd need to make a Listbox subclass, but I'm unsure of where to go from there.
So I've got a DialogWindow (subclass of Toplevel), and have my canvas and listbox in the DialogWindow. I've conjured up a way of getting a name from the listbox: when I click on a name, I convert it to a canvas.create_text object and then drag that. My issue is the drop. I try to use the canvas.canvasx to convert to canvas coordinates but it hasn't worked for me. x and y are still in listbox coordinates.
def onRelease(self, event):
x = self.canvas.canvasx(event.x)
y = self.canvas.canvasx(event.y)
print(event.x, event.y)
print(x, y) #Prints the same thing as the previous line
The key to drag and drop boils down to needing to do three things:
bind on <ButtonPress-1> to select the item to be dragged
bind on <B1-Motion> to do the drag
bind on <ButtonRelease-1> to do the drop
None of this requires any subclassing. All of these bindings are on the listbox widget. You'll probably want to create an instance of Toplevel with a text label in it and the window decorations removed (using wm_overrideredirect(True)) to represent the item being dragged.
On the drop, you'll need to convert the coordinates of the mouse to canvas coordinates using the canvasx and canvasy methods of the canvas. Instead of starting with event.x and event.y (which are relative to the listbox), use the winfo_pointerxy method to get the screen coordinates of the mouse, then do a little math.
Here's an example of how you could do the drop:
def _on_drag_drop(self, event):
i = self.listbox.curselection()[0]
text = self.listbox.get(i)
wx, wy = self.canvas.winfo_rootx(), self.canvas.winfo_rooty()
x,y = self.winfo_pointerxy()
cx = self.canvas.canvasx(x-wx)
cy = self.canvas.canvasy(y-wy)
self.canvas.create_text(cx,cy,text=text, anchor="sw")
self.canvas.configure(scrollregion=self.canvas.bbox("all"))

Trying to position a button programmatically, however not in right position according to X,Y

I'm trying to position a button.
Here is the code for the positioning..
[btnAbs setFrame:CGRectMake(57, 50, 106, 99)];
The coordinates I got are from here:
As you can see the xib stats the x & y to be at 57 and 192, which is where I want the button to be.
However when I run it in simulator, here is where its placed:
Obviously i could keep guessing and guessing the x and y coordinates, but this is very time consuming. So how come it's doing this?
Please join the links together when looking at the pics as i need more than 10 reps to post images, or a mod fix this please?
The problem is here:
The “origin” in Interface Builder doesn’t actually affect how the view gets positioned programmatically—it’s just a visual aid. If you click the dot in the top left of that box, the X and Y coordinates will change to the top-left of the view, which are the coordinates you want to pass to -setFrame:.
It looks to me as if you have the GUI designer aligning base upon the center center of your image view. When you do it in code, it is going to align based upon the top left of the image view.
Further, your code places it at a y of 50, where your GUI designer is showing a y coord. of 192.

how to get x and y coordinates of user tap/touch relative to window - android titanium mobile?

Can any one tell how to get x and y coordinates of user tap/touch relative to window - android titanium mobile??
I need to add a popup view close to tableviewrow when the user select a row. How to determine the x,y (top/left) positions?
This might help you as the window or object touch events can help you find the exact points the user have touched on screen.
thanks
you can use
row.addEventListener('click',function(e){
alert('left:'+ e.x + ' top:'+ e.y);
});
where row is an object of Titanium.UI.TableViewRow. For other objects (like window/view), you can use same eventlistener.
But remember one thing: it gives the co-ordinates with respect to the corresponding row. i.e. you may get same co-ordinates for all the rows.
Therefor, if you want to popup something on that co-ordinate, you should addEventListener to the main window.
On click event of any view or object you get x and y coordinate see this link for more reference:
Titanium.UI.Window