2016-11-24 1 views
2

Ich brauche eine Methode ermöglicht langes Klicken auf den "Passwort" -Raum, da es ein "Auge" auf der gleichen Linie hat, aber nicht herausfinden, separate ID. Aber das Programm, das ich schrieb, machte keinen langen Klick. Bitte korrigieren Sie meinen Code:Langer Klick in Python

def testDevice1(self): 
    time.sleep(5) 


    username=self.driver.find_element_by_id('com.eas.android:id/front_edit') 
    username.send_keys('[email protected]') 
    time.sleep(5) 
    password = self.driver.find_element_by_id('com.eas.android:id/password') 
    password.send_keys('111111') 
    time.sleep(5) 
    self.driver.longClick('com.eas.android:id/password') 
    time.sleep(10) 
    self.driver.save_screenshot('/home/nat/PycharmProjects/touchoneautomation/appiumTests/screenshots/shot1.png') 
    self.driver.find_element_by_id('com.eas.android:id/btn_login').click() 
    self.driver.save_screenshot('/home/nat/PycharmProjects/touchoneautomation/appiumTests/screenshots/shot1.1.png') 
    time.sleep(5) 
    self.driver.save_screenshot('/home/nat/PycharmProjects/touchoneautomation/appiumTests/screenshots/shot1.2.png') 
    self.driver.find_element_by_id("com.eas.android:id/panel_logout").click() 
    time.sleep(5) 

Antwort

0

(Python) nachschlagen TouchAction. Sie können Befehle zusammen stringieren:

from appium.webdriver.common.touch_action import TouchAction 
ta = TouchAction(driver) 
ta.press(x=x, y=y).release().perform() 

# some_web_obj = driver.find... 
ta.press(some_web_obj).wait(duration_in_millisec).release().perform() 
Verwandte Themen