appium: prime cuts
TRANSCRIPT
ABOUTTHESPEAKERDanCuellar@thedancuellar
• CreatorofAppium• PrincipalDevelopmentManageratFOODit• PreviouslyatShazam,Zoosk,andMicrosoft• BSinComputerSciencefromCarnegieMellon
2
• ModernUWP(UniversalWindowsPlatform)apps• Win32applications(includingpre2000)• WPFapps• WindowsFormsapps• Webviews*(sometimes)• OfficePlugins
7
• CurrentlyrunseparatelyfromAppium
• SupportsOSX10.7andhigher
• Supportsdetailsmouseactions
• SupportsNativeDOM
• DoesnotcurrentlysupportWebViews,butitispossibletoaddthis11
• platform:mustbesettoMacforAppium forMac
• implicitTimeout:millisecondstotrybeforegivinguponfindinganelement
• loopDelay:delayinmillisecondsbetweenpollinginpollingloops(e.g.findelement)
• mouseMoveSpeed:0-100(50isnormal)
• diagnosticsDirectoryLocation:directoryfordiagnosticsoutput• screenShotOnError:1toenable,0todisable
12
• driver.get("Calculator”)– launchthecalculatorapp
• driver.find_element_by_xpath(“//AXApplication[…]/…”)– findelement
• element.click()– clickanelement
• element.text – gettextforanelement13
• accessibilityIdentifier – anidentifierthatwillbeusedforthepurposesofUIautomation
• accessibilityLabel – alabelwhichassistivedeviceswillusetodescribeaUIelements
• accessibilityHint – addscontexttotheaccessibilitylabelwhenmoreexplanationisnecessary
19
Method2Programatically
Objective-C[myElement setAccessibilyIdentifier:@”AwesomeValue”]myElement.accessibilityIdentifier =“AwesomeValue”;
SwiftmyElement.accessibilityIdentifer =“AwesomeValue” 21
Ifyouaren’tseeingyourIDscheckyourselfandyourparentelements• isAccessibilityElement – whensettofalsetheelementisnotintheaccessibilityDOM
• accessibilityElementsHidden – hidethechildrenofthiselementfromtheaccessibilityDOM
Also,youmayneedtomakesurethattheUIElement implementstheUIAccessibility protocol
25
• Xcode 7andiOS9donotsupportinstallingthespeeduptoolautomaticallythatpreviousversionsofAppium used• Noworries,youcaninstallitmanually
• https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/iwd_xcode7.md
• NowyouriOStestswillbefastagain
• iOS10andup,thesimulatortakesawhiletoboot• Thebestworkaroundistowarmthemupinadvance 28
• iOSandAndroid• autoWebView – startinthewebview context(reallyusefulforCordovaapps)
• Android• ignoreUnimportantViews – canspeedupyourAndroidtests• nativeWebScreenshot – takesthescreenshotfromUIAutomatorinsteadofchromedriver 29
• iOS• locationServicesAuthorized – pre-authorizeslocationservices(preventsanalert)
• Auto[Accept|Dismiss]Alerts – usefultopreventalerts• nativeWebTap – usesnon-javascript tapsonwebcontent• safariIgnoreFraudWarning – allowshttpswithoutpropercerts• interKeyDelay - timebetweenkeystrokes• sendKeyStrategy – (oneByOne,grouped,orsetValue) 30
driver.setNetworkConnection(value)[Androidonly]
Value(Alias) Data Wifi AirplaneMode0(None) 0 0 0
1(Airplane Mode) 0 0 1
2(Wifi only) 0 1 0
4(Dataonly) 1 0 0
6(AllNetwork on) 1 1 0
31
• XPathisslow• Avoidusingitwherepossible• Ifyoudouseit,doitasasub-searchonamorequicklyfoundelement
• Implicittimeoutsavescodebutcanslowdowntests• Negativechecks(e.g.elementdoesnotexist)alwaystakethetimeout
• ReplacenegativecheckswithfindElements()callsandthencheckthecount32
• Becauseofthewayit’simplemented• Ratherthanreimplement XPathsearchingfornativeelements,wetookalesscomplicatedandbrittleapproachWegenerateanXMLrepresentationofthedocument(EXPENSIVE)thensearch
• Pros• XPathisalwayscorrectandaccurateasweuseastandardimplementation
• Mucheasiertomaintain
• Cons• It’sslowbecausewemustgenerateamodeloftheentireDOM
33
MOREINFO• Website:http://www.appium.io
• Slack:appium.slack.com
• Forum:discuss.appium.io
• GitHub:http://www.github.com/appium/appium 35