How to scroll to a element which is not visible in appium? - appium

In the previous version of Appium, I can use scroll functions to scroll to the particular element which is not visible on the screen.
My requirement is I have a Layout, in which many elements are there and that layout is scrollable. The element which I want to click is not visible on the screen and I have to scroll to a particular element and click that?
Can someone help me out on this issue how to scroll to the particular element?

In latest version of appium to scroll on the screen or to scroll the tables or to implement drag and drop functionalites we have to use TouchAction.
If we want to scroll in a scrollable layout first we have to get the bounds of that layout and give the coordinates in side that bounds.
Consider the below line of code.
new TouchAction(driver).press(300,200).moveTo(300,100).release().perform();
In this line of code we will perform the scroll down by 100 points.
.press(300,200) // Start at 300,200
.moveTo(0,100) // Increase Y by 300, ending up at 300,100
You have to pass the coordinates based on your requirements.
Find the details in below link:
https://appium.io/docs/en/writing-running-appium/touch-actions/

Related

How to center content inside collection view in exact center of shown ring view while scrolling horizontally (iOS)?

I want to set center the content inside a UICollectionView according to ring image in the center of the whole screen. Please check the image below. Any Suggestions?
The function you need is this one... https://developer.apple.com/documentation/uikit/uicollectionviewdelegate/1618007-collectionview
This function is called by the collection view when the user finishes scrolling. It provides the content offset of where the collection view will stop scrolling. (The proposed content offset).
You then need to take that offset and work out the nearest offset to place your cell in the middle of the screen.
Something like, find the item that will be closest to the middle. Work out how far away from the middle it is so you know how much to shift it by. Then apply that shift to the proposed content offset.
This will allow your collection view to decelerate naturally but always stop at the point that you want it to stop.

Scrolling Programmatically THorzScrollBox Firemonkey XE6

I have a THorzScrollBox in a form, and some TStyledControls inside. Each StyledControl has a Tag to identify. Using an TEdit to inform a value, I can find inside the ScrollBox an specific Control by his tag.
If the control that I searched is not on the screen, I want to scroll the ScrollBox to show it.
How can I do this programmatically?
I found a way to do this.
I have to use ScrollBy. But the detail is that if I want to scroll the controls to right I have to use a negative value.
Example:
sbItems.ScrollBy(-10, 0); // this will scroll to right
If I use a positive value, it will scroll to left.
sbItems.ScrollBy(10, 0); // this will scroll to left
The point is, if you scroll once, the ViewportPosition will change and the next time you execute ScrollBy, it will not reset the scroll position, it will scroll from the point you already have scrolled.

Xcode 6.1 IOS really long form

I am quite new to xcode.
I am trying to create a contact details form for an iPhone using the storyboard. The problem is that form is longer than the display and I can't work out how to design it using the storyboard.
Any ideas?
Tom
In IB, you can set the controller's size in Simulated Metrics to Freeform, then select the view and make it as tall as you want. Then, add a scroll view to take up the whole view, and add your UIElements, and lay them out how you want. When you run the app, the view controller will still only be as big as the screen (obviously), but the scroll view will be as big as you made the view in IB (you may need to increase its contentSize even more to be able to scroll to the bottom).
Such forms are often made in storyboards using a UITableView and setting the "content" of the table to be "Static Cells." You can set any number of cells and the contents of the cell you want. The table itself is scrollable inside the storyboard/Interface Builder editor and looks much the way it would when presented to a user.
First, select the tableView on the left
Then, you can move it simply scrolling (on mac, two fingers on the trackpad, or using the mouse wheel)
You should have a look at UIScrollView, it is designed to support content larger than screen size (like you see in web browser or settings)
Basic usage is:
//Set a size which will be able to cover all form elements
[yourScrollView setContentSize:CGSizeMake()];
//Your scrollView now extends from CGPoint 0,0 to contentSize.width,contentSize.height.
//Your subviews should be positioned according to scrollview's bounds not the viewcontroller.view or any other container view.
//Add all the form elements
[yourScrollView addSubview:...];
[yourScrollView setDelegate:self]; //If you need actions after user scrolled etc.
Have a look at the developer manual for more info. Most method names are quite self explanatory.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html

Manipulating scroll view in Corona SDK

I have a class with a scroll view that has a width of 980. I also have about 100 buttons aligned 5 columns x 5 rows for each 320 width of my scroll view. The scroll works okay but I'm trying to achieve two things:
Allow scrolling only when slide length is about 50% of screen size
If the slide length is half the screen size, then it would immediately slide/scroll to the next 25 items. For example, in plain sight you would see buttons 1-25 then if you try to scroll, the next 25 objects would be displayed (buttons 26-50).
I followed the sample from here but I don't know how to implement what I want to do or if it's even possible to do this using scroll view. I hope someone can give me a good example or idea. Thanks.
Try something like this: http://developer.coronalabs.com/code/slider-module-springboard-functionality-warning-shameless-promotion-inside. It works sort of like the iOS springboard.

UIAutomation and reading static text in scroll view

I'm doing some UIAutomation testing using Xcode Instruments and have an issue accessing a staticText which I want to verify.
The situation:
I have some buttons that display different scroll views that contain multiple charts. These scroll views have 5+ items in each so when i initially do target.logElementTree() it only shows the visible ones. If i scroll down with window.scrollViews()[0].scrollDown() and again get a logElementTree() the bottom elements are shown however whenever i try to access them it keeps referring to the ones from the top of the scroll view.
Any ideas?
Cheers.
As per as my experience, whenever you do "taregt.logElementTree()", it will display you all the elements (visible & hidden or which are present even at the bottom of screen) which you can access by its name or index or position once scrolled down. But if you still face problem, I will recommend you to access the element by its position after scrolling down to make it visible.

Resources