I am trying to automate a native Android 4.2 application. The application plays a video and if you tap on the video a SeekBar widget which can be used to rewind the video is shown for 5 seconds.
The problem I am having is when I tap on the video to show the SeekBar widget it disappears too quickly before Appium can to do anything with it. e.g. get the seekbar coordinates for example.
Are there any solutions to this which don't require modifying the application itself? Is it possible to force the widget to always show for example? Or are there any other ways?
// tap to show the SeekBar widger
new TouchAction(driver).Tap(0.5, 0.5).Perform();
// get SeekBar element
IWebElement seekbar = new WebDriverWait(driver, TimeSpan.FromSeconds(60))
.Until(d => d.FindElement(By.XPath("//android.widget.SeekBar")));
// get its location.
// here is where test fails most of the time due to SeekBar widget disappearing too quickly.
var location = seekbar.Location;
Related
I am working on a small project for my own use and I need my accessibility service to perform a tap on the screen and show/hide the controls from video players such as Netflix or youtube.
So in my accessibilityService I use getRootInActiveWindow() and I get reference to the app window (com.netflix.mediaclient for example)
I then traverse through all the nodes and I do performAction(AccessibilityNodeInfo.ACTION_CLICK) but it seems none of the nodes are clickable (when the media player control is hidden, otherwise I can click on control buttons) and I can`t make the media player control to show up.
Any idea why this might be the case? Also, is it possible to perform a tap on the screen in general and not on a specific AccessibilityNodeInfo?
UPDATE
It turned out the issue was that ACTION_CLICK does not work as a TOUCH so if the view reacts to touch events but not to click events then ACTION_CLICK will not do anything. Unfortunately, it seems like there is no way to perform tap on AccessibilityNodeInfo objects.
I was unable to make the video player control to appear through accessibility nodes but I was able to achieve a similar effect by just mimicking a tap on a screen with following code.
private void click(int x, int y) {
Path path = new Path();
path.moveTo(x, y);
path.moveTo(x+10, y+10);
GestureDescription.Builder builder = new GestureDescription.Builder();
GestureDescription gestureDescription = builder.addStroke(new GestureDescription.StrokeDescription(path, 10, 200)).build();
dispatchGesture(gestureDescription, null, null);
}
And then I call the click function with something like 300, 300
Make sure to put
android:canPerformGestures="true"
in your AccessibilityService XML file.
I am still curious why I was not able to achieve the same with nodes though so please let me know if anyone is aware.
When I add a button in an AnchorPane (not in a PopUp like in this other test No detection of a touchScreen Button event in a modal window on Android), I have a kind of real time problem.
The test conditions are:
I often touch the same button. If the deltaOfTime between two touchScreen is greater than 1 second, the processing under the button is taken into account. When the deltaOfTime is lower, there is no action
I use JavaFXPorts (Gluon), with Eclipse and Gradle.
public void start() {
Button button = new Button("Action do do"));
HBox.setMargin(button , new Insets(10, 30, 10, 30));
button .setOnAction(e -> {
actionToDo();
});
Scene scene = new Scene (button, 100, 200);
Stage stage = new Stage();
stage.setScene(scene);
stage.show();
}
An idea? Does that mean that JavaFxPorts takes a lot of time to get events?
My application is a video game. Therefore, the final aim is to use the touchScreen for shooting, for instance, ... with deltaOfTime < 500 ms
Thanks
I create app for android in Adobe Flash Professional.
It is fragment of code.
stage.addEventListener( TouchEvent.TOUCH_OUT, _out );
function _out( e:TouchEvent):void
{
trace( "OUT!" );
}
When I move on some view object I obtain message. When I move on the screen and then move out the area of the screen I'm not receiving messages. What do?
Just to be sure, you are trying to trigger a function whenever the cursor is rolled out of the stage. In such a case, a naive option is check the coordinate of the mouse an to check if its on the stage or not. Whenever the cursor crosses the stage dimensions, the function can be triggered.
Another way is to use a transparent object on the stage and check collision of the mouse with that. Whenever the collision detection returns false, the function will be triggered.
TOUCH_OUT will not work on Windows debugging sessions, but it will work on your Android. Don't worry.
To avoid the event being triggered by on-stage objects, just set the property mouseChildren of all your MovieClips to false.
I have made 2 different animations in Adobe flash professional cs5.5 for an Android aplication.
And I want a code that makes it possible for a user of the app to play the animation as often they want, so if the user wants the animation to play 1 time the first animation will be playes, if the user wants to play it 2 times the animation 1 and 2 will be played, if the user wants the animation 3 times played the animation 1, 2 and 1 will be played and so on.
Can somebody help me with this problem and tell me if this is possible in jquery.
If I was you, the way I would approach this is by having a keyframe after each of the animations where you can type some code.
On the menu page or where ever you have the code for how many times the code should run, define a variable and call it something like "runTimes" which should become the amount of times the animation should run.
At the end of the animations do a simple if statement to check what the value of "runTimes" is and then decrement it. Depending on the value, it should use gotoAndPlay/gotoAndStop.
So, put this on the keyframe after the first animation:
if (runTimes > 0) {
runTimes--;
gotoAndPlay(<FIRST FRAME OF SECOND ANIMATION>);
} else {
gotoAndStop(<FRAME OF MAIN MENU>);
}
and this after the second animation:
if (runTimes > 0) {
runTimes--;
gotoAndPlay(<FIRST FRAME OF FIRST ANIMATION>);
} else {
gotoAndStop(<FRAME OF MAIN MENU>);
}
On the mainmenu frame, let's assume you have a textbox named "numTimes_txt" for the number of times to play and a button "playAnimations_btn" to start the animations.
import flash.events.MouseEvent;
var runTimes:int = 0;
playAnimations_btn.addEventListener(MouseEvent.CLICK, playAnims);
function playAnims(e:MouseEvent):void {
runTimes = parseInt(numTimes_txt.text);
play(); // or gotoAndPlay(<FIRST FRAME OF FIRST ANIMATION>);
}
I haven't tested this as I don't have my IDE on me right now, but this should work if I understand the question properly.
Is it possible to add markers to video's at regular intervals on the video view progress bar so that the video can stop at that point and start another activity? For instance at 10 min into a video I need a marker in the videoview progress bar, and when the video comes to 10 min, the video stops and the other activity starts ?
Yes, It possible, (Rough Idea..)
The exact method I don't know, but you can make a Hack.. By using methods
public int getDuration() and getCurrentPosition() of
MedaiPlayer class.
Basic Idea, What to do is make a ProgressBar (for complete video duration) and now when you add marker to it just get the duration of that marker (using some mathematical formula). And now check for current Position of your Video file, If its your marker position then using condition stop your video ans start a new Activity..
(If I'm going wrong let me know)