When the app gesture password is set with appium-desktop-setup-1.6.2, it is found that the method of move_to (x, y) relative offset is not used, and the drawn gestures are running.
and throw a mistake.
is outside of element rect: [0,0][720,1280]
The code is as follows
fromAppiumImportWebdriver fromSelenium.webdriver.support.waitImportwebdriverwait fromSelenium.webdriver.supportImportExpected_conditions as EC fromAppium.webdriver.common.mobilebyImportMobileby fromAppium.webdriver.common.touch_actionImporttouchaction fromTimeImportSleep#It's up to you to tell Appium server which app on which device I'm working on#desired capabilites, key-value pairs, key names are already defined#information preparation for manipulating objectsdesired_caps={}#operating system used by mobile phonedesired_caps["PlatformName"] ="Android"#version of the mobile operating systemdesired_caps["platformversion"]="5.1.1"#The type of device name or simulator useddesired_caps["devicename"]="Android Emulator"#App Infodesired_caps["Apppackage"]="Com.xxzb.fenwoo"#access to the interfacedesired_caps["appactivity"] =". Activity.addition.WelcomeActivity"#Connect to Appium server and tell it to manipulate the objectDriver=webdriver. Remote ('Http://127.0.0.1:4723/wd/hub', Desired_caps)#Get screen sizeSize=driver.get_window_size () forXinchRange (0,4): #Swipe leftDriver.swipe (size["width"]*0.9,size["Height"]*0.5,size["width"]*0.1,size["Height"]*0.5,500) #Swipe Right #driver.swipe (size["width"]*0.1,size["height"]*0.5,size["width"]*0.9,size["height"]*0.5,500)Sleep (1)#Click to experience nowWebdriverwait (driver,20,1). Until (Ec.visibility_of_element_located (mobileby.id,"Com.xxzb.fenwoo:id/btn_start")) ) driver.find_element_by_id ("Com.xxzb.fenwoo:id/btn_start"). Click ()#waitWebdriverwait (driver,30,1). Until (Ec.visibility_of_element_located (mobileby.id,"Com.xxzb.fenwoo:id/btn_login")))#Click the Sign in registration buttonDRIVER.FIND_ELEMENT_BY_ID ("Com.xxzb.fenwoo:id/btn_login"). Click ()#waitWebdriverwait (driver,30,1). Until (Ec.visibility_of_element_located (mobileby.id,"Com.xxzb.fenwoo:id/et_phone")))#Enter user nameDRIVER.FIND_ELEMENT_BY_ID ("Com.xxzb.fenwoo:id/et_phone"). Send_keys ("XXXXXX")#Click NextDRIVER.FIND_ELEMENT_BY_ID ("Com.xxzb.fenwoo:id/btn_next_step"). Click ()#waitWebdriverwait (driver,30,1). Until (Ec.visibility_of_element_located (mobileby.id,"com.xxzb.fenwoo:id/et_pwd")))#Enter PasswordDRIVER.FIND_ELEMENT_BY_ID ("com.xxzb.fenwoo:id/et_pwd"). Send_keys ("XXXXXX")#Click the OK buttonDRIVER.FIND_ELEMENT_BY_ID ("Com.xxzb.fenwoo:id/btn_next_step"). Click ()#waitWebdriverwait (driver,30,1). Until (Ec.visibility_of_element_located (mobileby.id,"com.xxzb.fenwoo:id/btn_confirm")))#set up nowDRIVER.FIND_ELEMENT_BY_ID ("com.xxzb.fenwoo:id/btn_confirm"). Click ()#waitWebdriverwait (driver,30,1). Until (Ec.visibility_of_element_located (mobileby.id,"Com.xxzb.fenwoo:id/btn_gesturepwd_guide")))#Create nowDRIVER.FIND_ELEMENT_BY_ID ("Com.xxzb.fenwoo:id/btn_gesturepwd_guide"). Click ()#waitWebdriverwait (driver,30,1). Until (Ec.visibility_of_element_located (mobileby.id,"com.xxzb.fenwoo:id/right_btn")))#OK buttonDRIVER.FIND_ELEMENT_BY_ID ("com.xxzb.fenwoo:id/right_btn"). Click ()#Gesture drawing pageTa=touchaction (Driver)#get the beginning coordinates and size of nine GonggeELE=DRIVER.FIND_ELEMENT_BY_ID ("Com.xxzb.fenwoo:id/gesturepwd_create_lockview") Size=ele.size#Get coordinatesStart_point=ele.locationta.press (x=start_point["x"]+size["width"]*1/6,y=start_point["y"]+size["Height"]*1/6). Wait (200). Move_to (x=size["width"]*2/6,y=0). Wait (200). Move_to (x=size["width"]*2/6,y=0). Wait (200). Move_to (x=-size["width"]*2/6,y=size["width"]*2/6). Wait (200). Move_to (x=0,y=size["width"]*2/6). Wait (+). Release (). Wait (200). Perform ()#wait#webdriverwait (driver,30,1). Until (ec.visibility_of_element_located (mobileby.id, "Com.xxzb.fenwoo:id/right_ BTN " )))#Click ContinueDRIVER.FIND_ELEMENT_BY_ID ("com.xxzb.fenwoo:id/right_btn"). Click ()
And a strange phenomenon is that the coordinate point of the first circle is (150, 379), the coordinates obtained after the relative offset (210, 0) are (210, 640)
And then I tried.
Ta.press (x=0, y=0). Release (). Perfrom ()
The magical Discovery (0, 0) is that the point is (360, 640) This position
If you try to get the coordinates of the press (X=0, y=10), the Press (x=10, y=0), the coordinate point is (10, 640), only when the press (x=10, y=10) gets the (10, 10), This can explain the above x=210, y=0, why is (210, 640). It looks like x or y can't be 0, or it'll run off.
This question has now been reported Bug,bug address: https://discuss.appium.io/t/ set-gesture-password-and-show-pressed-coordinate-error-using-1-6-2-appium-desktop-on-android-simulator/22858
The current solution is to use absolute coordinates to locate and modify the code as follows:
ta.press (x=start_point["x"]+size["width"]*1/6,y=start_point["y"]+size["Height"]*1/6). Wait (200). Move_to (x=start_point["x"]+size["width"]*3/6, y=start_point["y"]+size["Height"]*1/6). Wait (200). Move_to (x=start_point["x"]+size["width"]*5/6, y=start_point["y"]+size["Height"]*1/6). Wait (200). Move_to (x=start_point["x"]+size["width"]*3/6, y=start_point["y"]+size["width"]*3/6). Wait (200). Move_to (x=start_point["x"]+size["width"]*3/6, y=start_point["y"]+size["width"]*5/6). Wait (+). Release (). Wait ($). Perform ()
New Appium Draw a note for nine Gongge