-1

我正在爲不同的操作系統創建一個具有不同結構的Ionic應用程序,所以我想要使用多個find-element方法來定位一個元素並且要執行測試。如何實現這些基於條件的元素目標。在appium中找到基於多個條件的元素

if (first input box){ 
//do this 
} 

if else (input place holder "userName"){ 
//do this 
} 

if else (id with "userName"){ 
//do this 
} 

else{ 
//failed 
} 
+0

你使用哪種語言與客戶端? –

回答

1

也許只是試試/除?

Try: 

    el1 = self.driver.find_element_by_id('ID') 
    //do this 

Except NoSuchElementException: 
    pass 

Try: 

    el2 = self.driver.find_element_by_id('ID2') 
    //do this 

Except NoSuchElementException: 
    pass 

Try: 

    el3 = self.driver.find_element_by_id('ID3') 
    //do this 

Except NoSuchElementException: 
    self.faile('elements not found') 

或一些與 「isDisplayed」:

el1 = self.driver.find_element_by_id('ID') 
if el1.is_displayed(): 
//do this