How to use getAttributePrefix method in Airtest

Best Python code snippet using Airtest

utils.py

Source:utils.py Github

copy

Full Screen

...232 def getAttributeCount(self) :233 if self.m_event != START_TAG :234 return -1235 return len(self.m_attributes) / ATTRIBUTE_LENGHT236 def getAttributePrefix(self, index) :237 offset = self.getAttributeOffset(index)238 uri = self.m_attributes[offset+ATTRIBUTE_IX_NAMESPACE_URI]239 prefix = self.getPrefixByUri( uri )240 if prefix == -1 :241 return ""242 return self.sb.getRaw( prefix )243 def getAttributeName(self, index) :244 offset = self.getAttributeOffset(index)245 name = self.m_attributes[offset+ATTRIBUTE_IX_NAME]246 if name == -1 :247 return ""248 return self.sb.getRaw( name )249 def getAttributeValueType(self, index) :250 offset = self.getAttributeOffset(index)251 return self.m_attributes[offset+ATTRIBUTE_IX_VALUE_TYPE]252 def getAttributeValueData(self, index) :253 offset = self.getAttributeOffset(index)254 return self.m_attributes[offset+ATTRIBUTE_IX_VALUE_DATA]255 def getAttributeValue(self, index) :256 offset = self.getAttributeOffset(index)257 valueType = self.m_attributes[offset+ATTRIBUTE_IX_VALUE_TYPE]258 if valueType == TYPE_STRING :259 valueString = self.m_attributes[offset+ATTRIBUTE_IX_VALUE_STRING]260 return self.sb.getRaw( valueString )261 #int valueData=m_attributes[offset+ATTRIBUTE_IX_VALUE_DATA];262 #return TypedValue.coerceToString(valueType,valueData);263 raise("ooo")264TYPE_ATTRIBUTE = 2265TYPE_DIMENSION = 5266TYPE_FIRST_COLOR_INT = 28267TYPE_FIRST_INT = 16268TYPE_FLOAT = 4269TYPE_FRACTION = 6270TYPE_INT_BOOLEAN = 18271TYPE_INT_COLOR_ARGB4 = 30272TYPE_INT_COLOR_ARGB8 = 28273TYPE_INT_COLOR_RGB4 = 31274TYPE_INT_COLOR_RGB8 = 29275TYPE_INT_DEC = 16276TYPE_INT_HEX = 17277TYPE_LAST_COLOR_INT = 31278TYPE_LAST_INT = 31279TYPE_NULL = 0280TYPE_REFERENCE = 1281TYPE_STRING = 3282class AXMLPrinter :283 def __init__(self, raw_buff) :284 self.axml = AXMLParser( raw_buff )285 self.xmlns = False286 self.buff = ""287 while 1 :288 _type = self.axml.next()289# print "tagtype = ", _type290 if _type == START_DOCUMENT :291# print "<?xml version=\"1.0\" encoding=\"utf-8\"?>"292 self.buff += "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"293 elif _type == START_TAG :294# print "<%s%s" % ( self.getPrefix( self.axml.getPrefix() ), self.axml.getName() ),295 self.buff += "<%s%s\n" % ( self.getPrefix( self.axml.getPrefix() ), self.axml.getName() )296 if self.xmlns == False : 297# print " xmlns:%s=\"%s\" " % ( self.axml.getNamespacePrefix( 0 ), self.axml.getNamespaceUri( 0 ) )298 self.buff += "xmlns:%s=\"%s\"\n" % ( self.axml.getNamespacePrefix( 0 ), self.axml.getNamespaceUri( 0 ) )299 self.xmlns = True300 for i in range(0, self.axml.getAttributeCount()) :301# print "%s%s=\"%s\"" % ( self.getPrefix( self.axml.getAttributePrefix(i) ), self.axml.getAttributeName(i), self.getAttributeValue( i ) )302 self.buff += "%s%s=\"%s\"\n" % ( self.getPrefix( self.axml.getAttributePrefix(i) ), self.axml.getAttributeName(i), self.getAttributeValue( i ) )303# print ">"304 self.buff += ">\n"305 elif _type == END_TAG :306# print "</%s%s>" % ( self.getPrefix( self.axml.getPrefix() ), self.axml.getName() )307 self.buff += "</%s%s>\n" % ( self.getPrefix( self.axml.getPrefix() ), self.axml.getName() )308 elif _type == TEXT : 309# print "%s" % self.axml.getText()310 self.buff += "%s\n" % self.axml.getText()311 elif _type == END_DOCUMENT :312 break313 else :314 raise("ooo")315 def getBuff(self) :316 return self.buff...

Full Screen

Full Screen

axmlprinter.py

Source:axmlprinter.py Github

copy

Full Screen

...36 self.buff += "xmlns:%s=\"%s\"\n" % (self.axml.getNamespacePrefix(0), self.axml.getNamespaceUri(0))37 self.xmlns = True38 for i in range(0, int(self.axml.getAttributeCount())):39 self.buff += "%s%s=\"%s\"\n" % (40 self.getPrefix(self.axml.getAttributePrefix(i)), self.axml.getAttributeName(i),41 self.getAttributeValue(i))42 self.buff += ">\n"43 elif _type == tc.END_TAG:44 self.buff += "</%s%s>\n" % (self.getPrefix(self.axml.getPrefix()), self.axml.getName())45 elif _type == tc.TEXT:46 self.buff += "%s\n" % self.axml.getText()47 elif _type == tc.END_DOCUMENT:48 break49 def getBuff(self):50 return self.buff.encode("utf-8")51 def getPrefix(self, prefix):52 if prefix == None or len(prefix) == 0:53 return ""54 return prefix + ":"...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful