-3
PLS找到代碼如下:Catch塊是沒有得到執行
public static void selectDefinition(String defName)
{
driver.findElement(By.xpath("//table[@id='MainContent_gdvDefs_DXMainTable']//td[text()='"+defName+"']")).click();
}
和
try{
selectDefinition(defdelname);
System.out.println("Definition "+defdelname+" was not removed from the table");
}
catch (Exception ex)
{
System.out.println("Definition "+defdelname+"was removed successfully from the table");
}
在上面的代碼
如果「defdelname」被刪除的catch程序塊不是正在執行,但對於selectDefinition它沒有拋出這樣的元素異常。
我是一個初學者請幫我解決這個問題我想要catch塊執行任何解決方法嗎?
請正確格式化您的代碼。 – TheLostMind
您的代碼是不可編譯的。請糾正你的例子。 'try/catch'目前在任何方法之外。 –
在這個例子中,如果拋出異常,它只打印「成功」。你不應該認爲在你打電話時刪除成功了嗎? –