2015-07-13 188 views
9

更新
参考文献:perfecto mobiledevice anywhere如何从浏览器控制手机屏幕?


我就应该同时支持iOS和Android基于云的移动测试解决方案的工作。它要求连接的移动设备通过浏览器进行处理。

我已经了解到,移动装置具有程序的代理排序(这要求装置能够根)安装的

  • 流移动屏幕给浏览器
  • 和注入事件

有没有其他方法可以实现这个可能没有生根/监狱破坏设备?

这个问题可能看起来很宽泛,但我一直在努力找出正确的方向。

对于iOS,我从this SOF question得知线索。

任何指针赞赏。


更新1:
This question接近我所期待的。

更新2: 我发现Android Screen Library Android设备,并测试了几个设备。它不需要设备被植入,但需要在每个设备重新启动时从命令行重新启动服务,并且无法在棒棒糖上运行。

更新3: 虽然Android Screen Library在捕捉帮助屏幕,不生根,但它不能在注射事件提供帮助。即使屏幕截图似乎越野车 - 有时用黑色补丁捕获,并不适用于棒棒糖!

更新4: 参考文献:perfecto mobiledevice anywhere 看来他们是用ADB来处理应用程序一样多的东西安装/卸载,通过adb shell input tap x y发送事件。任何人都可以摆脱一些光?

更新5: 我从Adrian Taylor,一名前工程师的RealVNC遇到this SO Post。这是最详细的解释。尽管Android棒棒糖有MediaProjection API,但它似乎将屏幕截图存储为SD卡上的MP4文件。另外,根据google dashboard - 2015年8月的更新,Lollipop仍然是Android安装基地的15%左右,因此任何解决方案都必须考虑到Kitkat。

更新6: 我找到了libvncserver,想知道它是否能完成这项工作。我会测试并发布结果。

感谢

+1

请用你的投票加入评论;)它会帮助我。 – iuq

+0

我不确定它是不是您想要的,但您可以使用JavaScript自动进行UI测试。 [教程](http://code.tutsplus.com/tutorials/introduction-to-ios-testing-with-ui-automation--cms-22730),[Documentation](https://developer.apple.com/ library/mac/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/UsingtheAutomationInstrument/UsingtheAutomationInstrument.html) –

+0

@Islam Q--谢谢,这确实是不错的文章。但是我的问题与其更多关于连通性的问题并没有什么不同,而且解决方案将主要用于手动测试。 – iuq

回答

4

使用WebKit的,这将让你很接近你可以得到,仍然更可能通过审批程序与苹果

这里有一个简单的例子,这基本上使得选择在网页上向应用程序发送字符串值,然后处理 该值并返回结果,然后将其作为网页的标题发布。

<h2 id="headline">loading...</h2> 
<select id="selector"> 
    <option value="systemVersion" selected>iOS Version</option> 
    <option value="systemName">System Name</option> 
    <option value="name">Device Name</option> 
    <option value="model">Device Model</option> 
    <option value="userInterfaceIdiom">User Interface</option> 
    <option value="identifierForVendor">Vendor ID</option> 
</select> 

这里的JavaScript:

var headline = $("#headline"); 
var selection = $("#selector"); 

function set_headline (text) { 
    headline.text(text); 
} 

function call_native() { 
    var prop = selection.val(); 
    set_headline("asked for " + prop + "..."); 
    window.webkit.messageHandlers.observe.postMessage(prop); 
} 

setTimeout(call_native, 1000); 
selection.on("change", call_native); 

在应用端,设置了以下内容:在屏幕上

[controller addScriptMessageHandler:self name:@"observe"]; 
configuration.userContentController = controller; 
NSURL *jsbin = [NSURL URLWithString:k_JSBIN_URL]; 

_webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:configuration]; 
[_webView loadRequest:[NSURLRequest requestWithURL:jsbin]]; 
[self.view addSubview:_webView]; 

手柄webView的

//配置web视图和地方的WebView事件:

-(void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message 
{ 
// Check to make sure the name is correct 
    if ([message.name isEqualToString:@"observe"]) { 
     // Log the message received 
     NSLog(@"Received event %@", message.body); 

     // Then pull something from the device using the message body 
     NSString *version = [[UIDevice currentDevice] valueForKey:message.body]; 

     // Execute some JavaScript using the result 
     NSString *exec_template = @"set_headline(\"received: %@\");"; 
     NSString *exec = [NSString stringWithFormat:exec_template, version]; 
     [_webView evaluateJavaScript:exec completionHandler:nil]; 
    } 
} 
+0

感谢您的回复。它只适用于Web/Hybrid应用程序或本机应用程序吗? ...对不起,我还没有在iOS上测试过任何东西,因为我仍然试图解决Android解决方案。 – iuq

+0

这是纯粹的本地,这不是混合,它在这种情况下所有的ObjC,这就是为什么它如此强大 – Loxx