DeltaXY - eng forum topic - http://forums.reprap.org/read.php?178,666239
DeltaXY - ru forum topic - http://roboforum.ru/forum107/topic16534.html
window_size = self.driver.get_window_size() # tap ok buttonpositions = []positions.append((window_size['width']/2, window_size['height']*0.7))self.driver.tap(positions)
In my app key code 152 is a signal to activate testing mode, when app receive this signal it just adds TextView on top left with "TestActivated" textdef activeTestMode(self): # activate test mode self.driver.press_keycode(152);
if ((event.getKeyCode()==152) && (event.getAction() == KeyEvent.ACTION_DOWN))Next i used Apium api to find this control:
{
appiumPipe = new TextView(this);
appiumPipe.setId(123456);
appiumPipe.setTag("AppiumPipe");
appiumPipe.setText("TestActivated");
appiumPipe.setBackgroundColor(Color.RED);
appiumPipe.setSingleLine(true);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.TOP);
params.setMargins(0, 0, 0, 0);
appiumPipe.setLayoutParams(params);
frame.addView(appiumPipe);
return true;
}
When control found the control text used as a pipe between app and my Appium python script.els = self.driver.find_elements_by_class_name('android.widget.TextView') # find_elements_by_xpath('//android.widget.TextView[*]')print els # find textviewfor element in els: if element.text=="TestActivated": self.AppiumPipe = element break
def updateTestInfo(self): self.driver.press_keycode(153); time.sleep(1) #print "-------------------" #print self.AppiumPipe.text #print "-------------------" #print AppiumPipe.name self.data = json.loads(self.AppiumPipe.text) #pprint(self.data)
else if ((event.getKeyCode()==153) && (event.getAction() == KeyEvent.ACTION_DOWN)) {String res = NativeMethods.executeCommand("APPIUM:GetJSON", null); is a code in my app returns gson with my internal opengl controls
String res = NativeMethods.executeCommand("APPIUM:GetJSON", null);
appiumPipe.setText(res);
return true;
}
def controlCenterByPath(self,json,path): pCur = self.controlByPath(json,path); self.assertIsNotNone(pCur) return (pCur['x']+pCur['w']/2,pCur['y']+pCur['h']/2); def tapControlByPath(self,json,path): pos = self.controlCenterByPath(json,path) # set up array of two coordinates positions = [] positions.append(pos) self.driver.tap(positions)
self.updateTestInfo() # call this to update UI gson self.tapControlByPath(self.data["TopLevel"][0],"DialogPanel.OKButton")
self.updateTestInfo() time.sleep(1) nodialog = self.controlByPath(self.data["TopLevel"][0],"DialogPanel") self.assertIsNone(nodialog,"Reward must be closed")