2014-09-01 60 views
0

在我的RCP應用程序中,有些shell在某些情況下打開,我想處理它們。例如: :如果文件已經存在於文件夾中,覆蓋外殼將會打開。我想要覆蓋外殼,如果它會打開。如何在swtbot中處理不可預知的shell

我曾嘗試如果條件與殼是積極的,看代碼。但是,如果條件不適用於swtbot。它試圖點擊Overwrite shell上的Ok按鈕,即使覆蓋shell沒有打開。

見代碼:

if (swtBot.shell("Overwrite").isActive) { 
    swtBot.Button("Ok").click(); //This code is every time executing even if Overwrite shell is not opened. 
} else { 
    //doing some other operation 
} 
+0

我刪除了[標籤:外殼]標籤,因爲這似乎是有關的東西完全不同。 – tripleee 2014-09-01 10:17:50

+1

那麼使用'SWTBotShell.isOpen()'來代替呢? – ratiaris 2014-09-01 14:29:54

回答

0
try { 
swtBot.Button("Ok").click(); // it will click the button if the appropriate shell is active 
} catch(WidgetNotFoundException e) { 
//doing some other operation 
}