Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add terribly insecure cmd: executor for ISETool etc #63

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add terribly insecure cmd: executor for ISETool etc #63

wants to merge 2 commits into from

Conversation

sleekweasel
Copy link

My first C#!

I know this is horribly insecure, but we're using it for retrieving logs from the phone when the tests are running on a different host: ssh can't access the desktop processes.

def retrieve_phone_log
    tmp = 'wphonetemp'
    driver.execute_script("cmd:cmd /c \"rd /s/q #{tmp} & md #{tmp}\"")
    isetool = 'c:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Tools\IsolatedStorageExplorerTool\ISETool.exe'
    $devices ||= driver.execute_script("cmd:\"#{isetool}\" enumeratedevices").split("\n")
    $devindex ||= $devices.grep(/#{driver.capabilities['deviceName']}$/).first.split.first
    log = driver.execute_script("cmd:\"#{isetool}\" ts deviceindex:#{$devindex} #{ENV['WINPHONE_APP_ID']} #{tmp}")
    log + driver.execute_script("cmd:cmd /c \"tree /f /a #{tmp} & type #{tmp}\\IsolatedStore\\BadooDebugLog.txt & echo DONE.\"")
end

@NickAb
Copy link
Contributor

NickAb commented Jan 14, 2016

@sleekweasel Thanks, looks nice. But I think we might have a simpler solution for your problem.

As I understand you need to retrieve log files from app that is running/installed on device.
We have some code implemented to upload files into local app storage on device in Winium.StoreApps. It uses API that also includes methods for downloading files from devices.

So I can back port it into winphonedriver and you would be able to download file. From this point there are two options:

  1. command will download file to any path on the system where the driver is running and then you would be able to read file content using some remote connection.
  2. command will download file and then read its content and return it as a string, so that you could get your logs right into test script.

To do this I just need to better understand what isolated storage do you need to access to. There are, I believe, three types or folders: "Local", "Roaming" and "Temp". Do you need to get files from "Local" only or from other folders too?

What do you think about this approach and which option would you prefer?

@sleekweasel
Copy link
Author

I need the data on the host running the tests, so that would be option 2, please. And yes, I think I only need local storage.

I'm also wanting to capture the Outerdriver's logfile for the duration of each given test: for analysing inefficiencies in tests' queries, and the ability to kill the emulator when convenient. I had planned to structure that around this 'cmd:' trick, but looks like I'll need something more elegant. :)

@NickAb
Copy link
Contributor

NickAb commented Jan 16, 2016

i think the logging part might be done by implementing /session/:sessionId/log. But we will have to rewire logging to sessions and add special logger handler.

@NickAb
Copy link
Contributor

NickAb commented Jan 16, 2016

Looking at webdriver and appium commands it seems that appium's driver.pull_file fits the task of downloading files from app storage better than what I proposed before (custom execute command).

@NickAb
Copy link
Contributor

NickAb commented Jan 19, 2016

@sleekweasel check #64

This PR adds implementation for PushFile and PullFile commands from Appium's mobile json wire protocol. See usage in PR description.

@sleekweasel
Copy link
Author

Thanks for doing this, and sorry it's taken me ages to get back - log file retrieval is kind-of a luxury item compared to just getting tests written at the moment! I will obviously use this once we bump our version. :)

@NickAb
Copy link
Contributor

NickAb commented Jan 30, 2016

@sleekweasel no problem, does it wok for your case? I asking because the logs are sometimes/usually stored in Temp storage, not the Local storage. If so, I will need to make some minor updates to #64

@NickAb
Copy link
Contributor

NickAb commented Jul 16, 2016

@sleekweasel any updates on logs retrieval?

@sleekweasel
Copy link
Author

Hi. Not yet, sorry - we haven't bumped our version and I'm buried in iOS stuff at the moment. :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants