第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如果發(fā)生某種異常,請重新啟動 selenium 中的測試

如果發(fā)生某種異常,請重新啟動 selenium 中的測試

慕森王 2023-08-04 17:41:33
我正在通過 kobiton 運行我的 selenium 移動測試,我不斷發(fā)現(xiàn)的一個問題是,當(dāng)我使用公用電話時,當(dāng)我嘗試運行測試時,它們可能正在使用中,我收到以下消息org.openqa.selenium.SessionNotCreatedException:沒有與所需功能匹配的設(shè)備我當(dāng)前的代碼設(shè)置是@BeforeClasspublic void setup()throws Exception{    String kobitonServerUrl = "https://f:a15e3b93-a1dd3c-4736-bdfb- 006221ezz8c2a2cz@api.kobiton.com/wd/hub";    this.driver = new RemoteWebDriver (config.kobitonServerUrl(), config.desireCapabilitites_iphone8());}我希望能夠嘗試    this.driver = new RemoteWebDriver (config.kobitonServerUrl(), config.desireCapabilitites_iphone9() )如果 iphone 8 不可用,所以我認(rèn)為 if 和 else 可以工作,但我不知道如何針對特定異常執(zhí)行此操作?
查看完整描述

2 回答

?
撒科打諢

TA貢獻(xiàn)1934條經(jīng)驗 獲得超2個贊

如果我正確理解你的問題,你想要的東西類似于 if-else 但有例外,


一般來說,異常的“if-else”是“try-catch”。也就是下面的代碼片段


try{

   this.driver = new RemoteWebDriver (config.kobitonServerUrl(), config.desireCapabilitites_iphone8());

} catch(Exception e){

   // Do something if any exception is thrown

}

將執(zhí)行try中的內(nèi)容,如果拋出任何異常(在 try 中),將執(zhí)行catch中的代碼。


對于特定的異常,您還可以指定該異常(假設(shè)您已經(jīng)導(dǎo)入了該異常),如下所示


try{

   this.driver = new RemoteWebDriver (config.kobitonServerUrl(), config.desireCapabilitites_iphone8());

} catch(SessionNotCreatedException e){

   // Do something if SessionNotCreatedException is thrown

}


查看完整回答
反對 回復(fù) 2023-08-04
?
侃侃無極

TA貢獻(xiàn)2051條經(jīng)驗 獲得超10個贊

單獨捕獲異常


@BeforeClass

public void setup()throws Exception{


   try {

    String kobitonServerUrl = "https://f:a15e3b93-a1dd3c-4736-bdfb- 

006221ezz8c2a2cz@api.kobiton.com/wd/hub";


    this.driver = new RemoteWebDriver (config.kobitonServerUrl(), 

config.desireCapabilitites_iphone8());

}


catch (SessionNotCreatedException e){

    this.driver = new RemoteWebDriver (config.kobitonServerUrl(), config.desireCapabilitites_iphone9() )

}


   // if you want to use if else

 catch (Exception other){

      if ( other.getMessage().contains("SessionNotCreatedException ") )

    { 

       // do something

    }


 }

}


查看完整回答
反對 回復(fù) 2023-08-04
  • 2 回答
  • 0 關(guān)注
  • 174 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號