-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