2gis / Winium.StoreApps.CodedUi

Prototype of Winium.StoreApps driver using CodedUI. Implements JsonWireProtocol for automation of Windows Phone applications
10 stars 8 forks source link

A packaging error prevented this application from installing. #29

Closed gian-te closed 8 years ago

gian-te commented 8 years ago

Hi I've encountered an error in the Do() method in CommandExecutorBase clas saying: A packaging error prevented this application from installing.

I am attempting to push/install a .xap file to the windows phone using your driver similar to what Appium does when installing apk files from my local drive to the attached device. This xap file is the app that i will run tests on from my team's automation framework. I am encountering the said error in this line of code in the Driver. image

I am able to break point on your code by instantiating a remoteWebDriver with C# using this line of code on our team's framework: AutoDriver = new RemoteWebDriver(new Uri(mobileDevice.MobileUrl), capabilities); where mobile url is "http://127.0.0.1:9999",where AutoDriver inherits from IWebDriver and capabilities is:

capabilities = new DesiredCapabilities(); capabilities.SetCapability("locale", "en-US"); capabilities.SetCapability("app", mobileDevice.Path);

gian-te commented 8 years ago

I configured the build on the Winium solution on Any CPU and it now installed and launched by doing the ff steps: //if (PackageType.Framework != manifestInfo.PackageType && WinTrust.VerifyEmbeddedSignature(packageFile)) //{ // throw new Exception( // string.Format( // CultureInfo.CurrentUICulture, // Resources.InvalidPackaging, // new object[0])); //}

and set GlobalOptions.LaunchAfterInstall = true. when assigning a value to app

but I can't execute my selenium commands yet because it fails on SendPing(Session session). Even after commenting out the ping functionality it says: image

I will appreciate any help I can get with this. thank you

NickAb commented 8 years ago

Are you using device or emulator? Could you please provide full logs from the driver. You can copy them from console window by right clicking window title and selecting Mark option, then scrolling to the start and selecting all the way down. I believe pressing enter key after selection should copy it to buffer, or you can again right-click the title and select Copy option.

gian-te commented 8 years ago

If I understood the error correctly, I think "outerDriver" or listener in port 9999 was able to receive the AutoDriver.Manage().Window.Size command from our framework but when sending the command to the innerServer it failed. I think it is possible that there is a missing desired capability. In android we have desiredcapabilities called "androidDeviceSocket" , can you tell me thr equivalent of this desiredcapability in winium.storeapps.codedui driver? I have a feeling that this is what made it fail

Also, in this line: var commandToExecute = new Command(commandName, acceptedRequest.MessageBody);

commandToExecute.SessionId is always null

NickAb commented 8 years ago

Part of the reason we tried to prototype CodedUI is that it does not require adding any server into the app or adding any Internet Server capability directly to your app. If you are using device, then you can try rebooting the device, some time our CodedUI test server does not close correctly which might break following sessions. Note that it is more proof of concept than ready tool, it is not as stable as Winium.StoreApps for example.

gian-te commented 8 years ago

image

I will try to reboot the device

gian-te commented 8 years ago

For some reason I am still encountering the No connection could be made because the target machine actively refused it exception. Are there any settings that I need to configure in the windows phone 8.1 device for this to work? I am debugging your solution and it seems that the commands from my solution are being received in your solution and interpreted by JWP.. but it seems the problem is executing the command in the device..

NickAb commented 8 years ago

If you a trying to run tests on device, you should follow steps described in https://github.com/2gis/Winium.StoreApps.CodedUi/issues/1#issuecomment-94719621 to allow port forwarding of a port used by CodedUI server for ip over usb. Then set deviceIpAddress to localhost.

gian-te commented 8 years ago

I tried adding the registry keys: image

but I'm still encountering the error image Any help with this ConnectFailure status? I think it's probably the codedui test project not being deployed and is not running in parallel to the AUT in the device or it is not listening for commands.. Can you tell me how you debugged the codedui test project on your device?

NickAb commented 8 years ago

In your tests set debugCodedUI capability to true, this should skip CodedUI deployment. Run driver as usualy. But before running tests, do following steps:

Winium.StoreApps.CodedUITestProject is the test project that contains test class CodedUiTestLoop. Open CodedUiTestLoop.cs and add break point at Automator.Instance.Start(); so that you can step in and see if server started and is running. You can also add break points in PingExecuter or SocketServer to see if it gets ping command or any incoming request at all. Build this project and open Test Explorer (Test → Windows → Test Explorer). You should see a test named CodedUiTestMethod1. Run this test in debug mode, step into Start method to see if it working and continue to let the server run its way. Now you can run tests and you should be able to hit breakpoints if server started and is able to receive incoming requests

gian-te commented 8 years ago

Sometimes it works when I change the deviceIpAddress capability from localhost to the IP address of the device. I also modified the timeout from 2500 to 25000. It might have been an ipoverusb issue or something.. not sure. Changing the deviceIpAddress every once in a while might be a workaround for this situation.

gian-te commented 8 years ago

I'll investigate and look at the CodedUITestProject tomorrow. Thank you.

NickAb commented 8 years ago

One more thing you might try before debugging. If you are running on Windows 10 host system, try enabling Developer Mode on the host. If you are deploying to Windows 10 Mobile device try enabling Developer Mode on the device if you haven't done so (but I think you have done it already as you can side load the app on the device).

If you have setup registry keys as described, you can use 127.0.0.1 as deviceIpAddress, it should work. As you mentioned, timeout might be to low if you have some problems with ip over usb, we did not encounter any, so we used standard timeout as in other Winium drivers.

NickAb commented 8 years ago

Yes, it looks like Coded UI Test server was able to start and the driver was able to connect to Coded UU Test Server. getWindowSize is not implemented in this version of the driver. You can see what commands are implemented by looking at filenames in Winium.StoreApps.CodedUITestProject/CommandExecutors and Winium.StoreApps.Driver/CommandExecutors

Almost all of the commands have to be implemented on CodedUiTestProject side, Driver side has only session lyfe-cycle related commands and status command.

gian-te commented 8 years ago

It turns out that all I needed was to restart the machine after adding registry keys. I also restarted my phone and now able to debug coded ui project although u missed the step saying to set startup project to the sample project and run the driver from exe after building. Thank you