Swipe down on Android homescreen

Mobile Testing, Android App Testing.
SanMan
Posts: 204
Joined: Tue Apr 13, 2010 9:59 am

Swipe down on Android homescreen

Post by SanMan » Thu May 23, 2019 10:10 am

I want to swipe down on Android home screen to see notifications.

How can I do it.

Report.Log(ReportLevel.Info, "Touch gestures", "Swipe gesture with direction 'Down (90°)' starting from 'Center' with distance '5.0' with swipe duration'500ms' and step count '0' on item 'AndroidOS.TitleLine'.", repo.AndroidOS.TitleLineInfo, new RecordItemIndex(5));
repo.AndroidOS.TitleLine.Swipe(Location.Center, ValueConverter.ArgumentFromString<Ranorex.Core.Recorder.Touch.GestureDirection>("SwipeDirection", "Down (90°)"), ValueConverter.ArgumentFromString<Ranorex.Core.Distance>("Distance", "5.0"), ValueConverter.ArgumentFromString<Ranorex.Duration>("SwipeDuration", "500ms"), 0);
Delay.Milliseconds(500);

This does not do nothing when runned...

McTurtle
Posts: 259
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Swipe down on Android homescreen

Post by McTurtle » Thu May 23, 2019 1:59 pm

Hey man :)

AndroidOS automation is a bit flaky... Try this:
public void swipe(int x1, int y1, int x2, int y2)
		{
			string cmdLine = string.Format("/C \"C:\\Program Files (x86)\\Ranorex\\Studio\\Bin\\RxEnv\\Android\\Tools\\adb.exe\" shell input touchscreen swipe {0} {1} {2} {3}",
			                               x1,
			                               y1,
			                               x2,
			                               y2
			                              );
			
			System.Diagnostics.Process process = new System.Diagnostics.Process();
			System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
			info.FileName = "cmd.exe";
			info.Arguments = cmdLine;
			process.StartInfo = info;
			process.Start();
		}
		
		void ITestModule.Run()
		{
			swipe(300,30,300,500);
		}
Does it work?

Regards,
McTurtle