Nothing happens when I use app.DragCoordinates and app.SwipeLeft in REPL

FredrikHaglundFredrikHaglund SEUniversity, Developer Group Leader ✭✭

Hi!

I have created a very simple Xamarin.Forms test app with a TextCell with Context Actions. I want to create a unit test that swipes left over the cell to reveal the buttons.

I can start the app and launch Repl(). I can use tree and run queries. Commands like changing orientation works so I think the environment is ok.

Are there any known issues to these commands in the current version? Suggestions how to proceed?

Versions
Xamarin Studio 5.7
Xamarin.Forms 1.3.1
Xamarin.UITest 0.6.8
Test Cloud Agent 12.0

Repl commands

tree

[UIWindow > ... > UITableView] [UITableViewWrapperView > Xamarin_Forms_Platform_iOS_ContextActionsCell]
[UITableViewCellContentView > UIScrollView]
[Xamarin_Forms_Platform_iOS_CellTableViewCell] text: "Swipe ME"
[UITableViewCellContentView]
[UITableViewLabel] text: "Swipe ME"
[UITableViewLabel] text: "And I will crash!"
[_UITableViewCellSeparatorView]
[_UITableViewCellSeparatorView]
[UITableViewHeaderFooterView] text: "TABLE SECTION 2"
[_UITableViewHeaderFooterViewBackground]
[_UITableViewHeaderFooterContentView]
[_UITableViewHeaderFooterViewLabel] text: "TABLE SECTION 2"

app.Query(x=>x.Class("Xamarin_Forms_Platform_iOS_CellTableViewCell"))
app.Query(x=>x.Class("Xamarin_Forms_Platform_iOS_CellTableViewCell"))

Query for Class("Xamarin_Forms_Platform_iOS_CellTableViewCell") gave 1 results.
[
{
"Id": null,
ITableViewCell; frame = (0 0; 320 44); text = 'Swipe ME'; layer = >",
"Rect": {
"Width": 320.0,
"Height": 44.0,
"X": 0.0,
"Y": 55.5,
"CenterX": 160.0,
"CenterY": 77.5
},
"Label": null,
"Text": "Swipe ME",
"Class": "Xamarin_Forms_Platform_iOS_CellTableViewCell",
"Enabled": true
}
]

app.DragCoordinates(320,77,0,77)
app.DragCoordinates(320,77,0,77)

Dragging from [ 320, 77 ] to [ 0, 77 ].

app.SwipeLeft(x=>x.Class("Xamarin_Forms_Platform_iOS_CellTableViewCell"))

Swiping left on element matching Class("Xamarin_Forms_Platform_iOS_CellTableViewCell") at coordinates [ 160, 77,5 ]. >>>

Answers

  • FredrikHaglundFredrikHaglund SEUniversity, Developer Group Leader ✭✭

    An update.

    Trying to run this on a phisical device locally does not work either. It fails with an time out.

    Dragging from [ 356,25, 71,5 ] to [ 18,75, 71,5 ].
    HTTP POST { Url: { AbsolutePath: "/uia", AbsoluteUri: "http://192.168.134.117:37265/uia", Authority: "192.168.134.117:37265", Fragment: "", Host: "192.168.134.117", HostNameType: IPv4, IsDefaultPort: False, IsFile: False, IsLoopback: False, IsUnc: False, LocalPath: "/uia", PathAndQuery: "/uia", Port: 37265, Query: "", Scheme: "http", Segments: [ "/", "uia" ], UserEscaped: False, UserInfo: "", DnsSafeHost: "192.168.134.117", IsAbsoluteUri: True, OriginalString: "http://192.168.134.117:37265/uia" }, Arguments: "{"command":"uia.panOffset('{:x 356.25 :y 71.5}', '{:x 18.75 :y 71.5}', '{:duration 0.75}')"}" }
    POST Complete { StatusCode: 200, Contents: "{"details":"","outcome":"FAILURE","reason":"Timed out running command uia.panOffset('{:x 356.25 :y 71.5}', '{:x 18.75 :y 71.5}', '{:duration 0.75}')"}" }
    Error while performing DragCoordinates(356,25, 71,5, 18,75, 71,5, null)
    Exception: System.Exception: Underlying query failed with output: 
    {"details":"","outcome":"FAILURE","reason":"Timed out running command uia.panOffset('{:x 356.25 :y 71.5}', '{:x 18.75 :y 71.5}', '{:duration 0.75}')"}
      at Xamarin.UITest.iOS.iOSGestures.ValidateSuccessfulCalabashResult (Xamarin.UITest.Shared.Http.HttpResult result) [0x00000] in <filename unknown>:0 
      at Xamarin.UITest.iOS.iOSGestures.DragCoordinates (Single fromX, Single fromY, Single toX, Single toY, Nullable`1 duration) [0x00000] in <filename unknown>:0 
    

    Going blind and running a test in Test Cloud just assuming my code for DragCoordinates probably works. At least the application crashes as expected which it also does when I do a swipe manually. I guess it could be a time out to but thats hard for me to see.

                [Test ()]
                public void TestCase ()
                {
                    ConfigureTest ();
                    _app.Screenshot ("Just Started");
                    SwipeLeft ();
                    _app.Screenshot ("After DragCoordinates");                                                                                                                                                                                        
                }
    
                private void SwipeLeft()
                {
                    var bodyRect = _app.Query(c => c.Class ("Xamarin_Forms_Platform_iOS_CellTableViewCell")).Single().Rect;
                    float fromCenterX = bodyRect.CenterX * 0.9f;
                    _app.DragCoordinates(
                        bodyRect.CenterX + fromCenterX,
                        bodyRect.CenterY,
                        bodyRect.CenterX - fromCenterX,
                        bodyRect.CenterY);
                }
    

    Test here: https://testcloud.xamarin.com/test/ec6d955a-ac03-4fed-9bf0-424a19fc5e8e/

  • andy2005andy2005 DEMember

    I have the problem that when I swipeLeft () in the REPL () have the problem until he wipes over half of the image and then spring back . What can I do?

  • FredrikHaglundFredrikHaglund SEUniversity, Developer Group Leader ✭✭

    @andy2005 please ask a new question for your problem instead of hijacking this thread.

Sign In or Register to comment.