36
1 PRIME CUTS

Appium: Prime Cuts

Embed Size (px)

Citation preview

1

PRIMECUTS

ABOUTTHESPEAKERDanCuellar@thedancuellar

• CreatorofAppium• PrincipalDevelopmentManageratFOODit• PreviouslyatShazam,Zoosk,andMicrosoft• BSinComputerSciencefromCarnegieMellon

2

AGENDA• DesktopApps

• NewAppium GUI

• AdvancedAppium

3

4

5

https://github.com/Microsoft/WinAppDriver6

• ModernUWP(UniversalWindowsPlatform)apps• Win32applications(includingpre2000)• WPFapps• WindowsFormsapps• Webviews*(sometimes)• OfficePlugins

7

• Pen&Touchsupport

• MobilePhonesupport

• Xboxsupport

8

9

https://github.com/appium/appium-for-mac10

• 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

14

15

16

17

18

• accessibilityIdentifier – anidentifierthatwillbeusedforthepurposesofUIautomation

• accessibilityLabel – alabelwhichassistivedeviceswillusetodescribeaUIelements

• accessibilityHint – addscontexttotheaccessibilitylabelwhenmoreexplanationisnecessary

19

Method1XIBfileorStoryboard

defineintheaccessibilityinspector

20

Method2Programatically

Objective-C[myElement setAccessibilyIdentifier:@”AwesomeValue”]myElement.accessibilityIdentifier =“AwesomeValue”;

SwiftmyElement.accessibilityIdentifer =“AwesomeValue” 21

Method3UserDefinedRuntimeAttributes

definewiththekey“accessibilityIdentifier”andthetype“String”

22

Method1idproperty

setinAndroid Studio

23

Method2idproperty

setthepropertyandroid:id orandroid:name intheXML

24

Ifyouaren’tseeingyourIDscheckyourselfandyourparentelements• isAccessibilityElement – whensettofalsetheelementisnotintheaccessibilityDOM

• accessibilityElementsHidden – hidethechildrenofthiselementfromtheaccessibilityDOM

Also,youmayneedtomakesurethattheUIElement implementstheUIAccessibility protocol

25

26

CONTEXTS

27

NativeContext WebContext

• 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

36