2014-03-31 39 views
0

我試圖在切換應用程序時使用UI自動化來測試書寫和從UIPasteboard讀取。但是,腳本在切換到第二個應用程序後掛起。我試着讓測試進入睡眠狀態,以防止它掛起。我嘗試過使用waitForInvalidpushTimeout/popTimeout,這兩種方法似乎都不起作用,並且在第二個應用中登錄logElementTree之前,測試仍然掛起。iOS UIAutomation:切換應用程序

這是我的UI自動化腳本,使用waitForInvalid。 (該「紙板共享」按鈕,是它推出的第二個應用程序):是一個使用腳本pushTimeout/popTimeout

var target = UIATarget.localTarget(); 

target.frontMostApp().mainWindow().segmentedControls()[0].buttons()["1MB"].tap(); 
target.frontMostApp().mainWindow().buttons()["Pasteboard Sharing"].tap(); 

UIATarget.localTarget().frontMostApp().mainWindow().buttons()["Paste & Go"] 
    .tap(); 
UIATarget.localTarget().frontMostApp().mainWindow().buttons()["Paste & Go"] 
    .waitForInvalid(); 

target.frontMostApp().mainWindow().logElementTree(); 

在這裏:

var target = UIATarget.localTarget(); 

target.frontMostApp().mainWindow().segmentedControls()[0].buttons()["1MB"].tap(); 
target.frontMostApp().mainWindow().buttons()["Pasteboard Sharing"].tap(); 

UIATarget.localTarget().frontMostApp().mainWindow().buttons()["Paste & Go"] 
    .tap(); 

UIATarget.localTarget().pushTimeout(10); 
UIATarget.localTarget().frontMostApp().mainWindow().buttons()["Check Pasteboard"] 
    .withValueForKey(1, "isVisible"); 
UIATarget.localTarget().popTimeout(); 

target.frontMostApp().mainWindow().logElementTree(); 

回答

1

如果我理解正確的話,你要使用相同的腳本測試兩個應用。但是,如果您只使用UIA,則這是不可能的。使用UIAutomation,您只能有一個應用程序作爲您的目標。因此,切換到另一個應用程序將會「掛起」,因爲目標應用程序在後臺。我讀過一些地方,你可以使用Appium https://github.com/appium/appium在兩個應用程序之間進行交互,但我沒有自己使用它。

+0

Appium在後臺也使用UIAutomation。所以限制仍然是一樣的。雖然這適用於Android(帶或不帶appium) –

相關問題