From 6ecd988e1b378d07648d300cae1c56d56a39d0b2 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Sat, 28 Mar 2020 23:44:54 -0500 Subject: [PATCH 01/22] implement driver options --- .../android/AndroidMobileOptions.java | 33 +++ .../java_client/ios/IOSMobileOptions.java | 33 +++ .../remote/MobileCapabilityType.java | 2 +- .../java_client/remote/MobileOptions.java | 211 ++++++++++++++++++ .../io/appium/java_client/IntentExample.apk | Bin 39857 -> 50008 bytes .../android/AndroidOptionsTest.java | 114 ++++++++++ .../java_client/ios/IOSOptionsTest.java | 114 ++++++++++ 7 files changed, 506 insertions(+), 1 deletion(-) create mode 100644 src/main/java/io/appium/java_client/android/AndroidMobileOptions.java create mode 100644 src/main/java/io/appium/java_client/ios/IOSMobileOptions.java create mode 100644 src/main/java/io/appium/java_client/remote/MobileOptions.java create mode 100644 src/test/java/io/appium/java_client/android/AndroidOptionsTest.java create mode 100644 src/test/java/io/appium/java_client/ios/IOSOptionsTest.java diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java new file mode 100644 index 000000000..79420244c --- /dev/null +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -0,0 +1,33 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.appium.java_client.android; + +import io.appium.java_client.remote.MobileOptions; +import io.appium.java_client.remote.MobilePlatform; +import org.openqa.selenium.Capabilities; +import org.openqa.selenium.remote.CapabilityType; + +public class AndroidMobileOptions extends MobileOptions { + public AndroidMobileOptions() { + setCapability(CapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID); + } + + public AndroidMobileOptions(Capabilities source) { + this(); + merge(source); + } +} diff --git a/src/main/java/io/appium/java_client/ios/IOSMobileOptions.java b/src/main/java/io/appium/java_client/ios/IOSMobileOptions.java new file mode 100644 index 000000000..e9744246b --- /dev/null +++ b/src/main/java/io/appium/java_client/ios/IOSMobileOptions.java @@ -0,0 +1,33 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.appium.java_client.ios; + +import io.appium.java_client.remote.MobileOptions; +import io.appium.java_client.remote.MobilePlatform; +import org.openqa.selenium.Capabilities; +import org.openqa.selenium.remote.CapabilityType; + +public class IOSMobileOptions extends MobileOptions { + public IOSMobileOptions() { + setCapability(CapabilityType.PLATFORM_NAME, MobilePlatform.IOS); + } + + public IOSMobileOptions(Capabilities source) { + this(); + merge(source); + } +} diff --git a/src/main/java/io/appium/java_client/remote/MobileCapabilityType.java b/src/main/java/io/appium/java_client/remote/MobileCapabilityType.java index 1f0b0ccf2..0650115f2 100644 --- a/src/main/java/io/appium/java_client/remote/MobileCapabilityType.java +++ b/src/main/java/io/appium/java_client/remote/MobileCapabilityType.java @@ -124,7 +124,7 @@ public interface MobileCapabilityType extends CapabilityType { String EVENT_TIMINGS = "eventTimings"; /** - * This is the flag which forces server to switch to the mobile WSONWP. + * This is the flag which forces server to switch to the mobile JSONWP. * If {@code false} then it is switched to W3C mode. */ String FORCE_MJSONWP = "forceMjsonwp"; diff --git a/src/main/java/io/appium/java_client/remote/MobileOptions.java b/src/main/java/io/appium/java_client/remote/MobileOptions.java new file mode 100644 index 000000000..83f849fde --- /dev/null +++ b/src/main/java/io/appium/java_client/remote/MobileOptions.java @@ -0,0 +1,211 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.appium.java_client.remote; + +import org.openqa.selenium.Capabilities; +import org.openqa.selenium.MutableCapabilities; +import org.openqa.selenium.ScreenOrientation; +import org.openqa.selenium.remote.CapabilityType; + +import java.net.URL; + +public abstract class MobileOptions> extends MutableCapabilities { + + public String getPlatformName() { + return (String) getCapability(CapabilityType.PLATFORM_NAME); + } + + public T setApp(String url) { + return amend(MobileCapabilityType.APP, url); + } + + public T setApp(URL url) { + return setApp(url.toString()); + } + + public String getApp() { + return (String) getCapability(MobileCapabilityType.APP); + } + + public T setAutomationName(String name) { + return amend(MobileCapabilityType.AUTOMATION_NAME, name); + } + + public String getAutomationName() { + return (String) getCapability(MobileCapabilityType.AUTOMATION_NAME); + } + + public T setAutoWebview() { + return setAutoWebview(true); + } + + public T setAutoWebview(boolean bool) { + return amend(MobileCapabilityType.AUTO_WEBVIEW, bool); + } + + public boolean isAutoWebview() { + return (boolean) getCapability(MobileCapabilityType.AUTO_WEBVIEW); + } + + public T setClearSystemFiles() { + return setClearSystemFiles(true); + } + + public T setClearSystemFiles(boolean bool) { + return amend(MobileCapabilityType.CLEAR_SYSTEM_FILES, bool); + } + + public boolean isClearSystemFiles() { + return (boolean) getCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES); + } + + public T setDeviceName(String deviceName) { + return amend(MobileCapabilityType.DEVICE_NAME, deviceName); + } + + public String getDeviceName() { + return (String) getCapability(MobileCapabilityType.DEVICE_NAME); + } + + public T setEnablePerformanceLogging(boolean bool) { + return amend(MobileCapabilityType.ENABLE_PERFORMANCE_LOGGING, bool); + } + + public T setEnablePerformanceLogging() { + return setEnablePerformanceLogging(true); + } + + public boolean isEnablePerformanceLogging() { + return (boolean) getCapability(MobileCapabilityType.ENABLE_PERFORMANCE_LOGGING); + } + + public T setEventTimings(boolean bool) { + return amend(MobileCapabilityType.EVENT_TIMINGS, bool); + } + + public T setEventTimings() { + return setEventTimings(true); + } + + public boolean isEventTimings() { + return (boolean) getCapability(MobileCapabilityType.EVENT_TIMINGS); + } + + public T setFullReset(boolean bool) { + return amend(MobileCapabilityType.FULL_RESET, bool); + } + + public T setFullReset() { + return setFullReset(true); + } + + public boolean isFullReset() { + return (boolean) getCapability(MobileCapabilityType.FULL_RESET); + } + + public T setLanguage(String language) { + return amend(MobileCapabilityType.LANGUAGE, language); + } + + public String getLanguage() { + return (String) getCapability(MobileCapabilityType.LANGUAGE); + } + + public T setLocale(String locale) { + return amend(MobileCapabilityType.LOCALE, locale); + } + + public String getLocale() { + return (String) getCapability(MobileCapabilityType.LOCALE); + } + + public T setNewCommandTimeout(int seconds) { + return amend(MobileCapabilityType.NEW_COMMAND_TIMEOUT, seconds); + } + + public int getNewCommandTimeout() { + return (int) getCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT); + } + + public T setNoReset(boolean bool) { + return amend(MobileCapabilityType.NO_RESET, bool); + } + + public T setNoReset() { + return setNoReset(true); + } + + public boolean isNoReset() { + return (boolean) getCapability(MobileCapabilityType.NO_RESET); + } + + public T setOrientation(ScreenOrientation orientation) { + return amend(MobileCapabilityType.ORIENTATION, orientation); + } + + public ScreenOrientation getOrientation() { + return (ScreenOrientation) getCapability(MobileCapabilityType.ORIENTATION); + } + + // TODO: add new method for List + public T setOtherApps(String app) { + return amend(MobileCapabilityType.OTHER_APPS, app); + } + + public String getOtherApps() { + return (String) getCapability(MobileCapabilityType.OTHER_APPS); + } + + public T setPlatformVersion(String version) { + return amend(MobileCapabilityType.PLATFORM_VERSION, version); + } + + public String getPlatformVersion() { + return (String) getCapability(MobileCapabilityType.PLATFORM_VERSION); + } + + public T setPrintPageSourceOnFindFailure() { + return setPrintPageSourceOnFindFailure(true); + } + + public T setPrintPageSourceOnFindFailure(boolean bool) { + return amend(MobileCapabilityType.PRINT_PAGE_SOURCE_ON_FIND_FAILURE, bool); + } + + public boolean isPrintPageSourceOnFindFailure() { + return (boolean) getCapability(MobileCapabilityType.PRINT_PAGE_SOURCE_ON_FIND_FAILURE); + } + + public T setUdid(String id) { + return amend(MobileCapabilityType.UDID, id); + } + + public String getUdid() { + return (String) getCapability(MobileCapabilityType.UDID); + } + + @Override + public T merge(Capabilities extraCapabilities) { + super.merge(extraCapabilities); + return (T) this; + } + + protected T amend(String optionName, Object value) { + setCapability(optionName, value); + return (T) this; + } +} diff --git a/src/test/java/io/appium/java_client/IntentExample.apk b/src/test/java/io/appium/java_client/IntentExample.apk index b86d5e9b7857d5f3d2eeb75ff53d46116fded082..196ea90940af607535d0cf5c57e0c22c1d3e4af2 100644 GIT binary patch delta 7085 zcmc(k2Uru!+Q$<@uTrFnB2|%+(4}|jAP^O?P^HD7bZHCdK`DY5x`=>Emky$oK`vZ!=Rd!hDSS@U7Yt!F(uEK+fyl|p zK^|p0$_hF(?OZ4z$KkQ5?%Fv!K$)!E&}+SXOX(#6#p zRP0PDPf7#^p}=I^#qHGTB47v#mdFhOfk4G^a)XS7Xh0&*muS2pku;@Pwo&XI3J^$- zsrX57J_SJd^p`Jh-KF-gCVW|ekd={8SYN|bMOfQFQ`A($#8g+qOvFUK(cR!mt+2+_%i;ZSmYjN1M?@LsYZUfaJ|+i;b#=+>GpcCmBuKh7Ofry7js{?>;QN zI}@rsj!1k7VG((5lpV-spT5&&Rkm{~`RpJYx>{P}TD^yV!60+D6*HFx&)Qg{bJ5_F z7NyskLdh9eW#{%p(dPQ8sSL~VM-^M}qob`y1ay?m(u!zKFW>VN%Q7~Z4|rXLRRSa? zOQhKtoE~Q$z6p;rtFAB%-qyV9@;J56uci(raRv6X$(tZp`=8# z9=PpnC+eThe>sP9cv?iEssD~ZsdMXXO(~)`6P0XU+3A;aZst7~2$;#io`ekESI8F^6enLg<3*j4ZtPKp|MJ+tj>IqxMBy9Id=!12OVRgXUV8Z)reOodEq zf}F0#ez;;a@jTh-d_M!}&~!))QIg;2RPjtt-bA6fPuYxQ5rZmrX*3H5u*O`lciR;S zhS(W zB5rSG-qe`&Zt~6A!?>u24l0ZTzBl>HuzKO)!8p<+L~g%to1SqlH7Sl6 zVJ_6(D!CvaAtWj!1ZC+ml;}76h;^Q00dr8Sh-g*P0Q{it&?^jo8xuR?7=Yj+AH7EI zdQxE0CVhfs!j_*slB{D&JIBXq&40d{eGIIXn<`uSw{w;{dky||ebnCd8AX|hpV{_F+h z1Wut+jZd}f=JjI7(1KmOkGO$jv=0uSn0yd3!0KYPethj=Bu?!vNu*83Rx&XEI-$Dl zg8=izsT?Ddcq^si%pM?k;_@3kY{I%-e(|{i?MnYbgj)|fZb>h^EsSHARRS+@k0dxx z=tvlA*qu|nYVprrMhwW-O7-yZ-FK2PTqS3hNG5JMQ7my-!XDQf0Dp~XG}C3zpzDh6 zycIp>rF@D0ilwB*6`P&N*xh)QtTe~ZCCRRmm{mWsZ=J-;1d>ZhR;bZ`fD#$dQhn0 zbRAK}Owkj^UDo3(0n;ww!6P4s<9CJi3wkKt51QA>G$DG^%?y4cYnUg);uN=D6uw%n z-L{qYnbEDE$=>0+`Vf7rkmc#b=7y9Kj^kb9>1FKY^}C}yy(TC7IqH)o1*C~D$XYER zH&cb!I$CWn(C5rNO>EbjTZ5KdJA-Y-Z0KsW334Tg*7X*IECNi>utN}LN7B1tqz>WS zaj9ApB92Hq2P>QSCpGMTZ_Zq)noj3q$rF)Zc^lJIip|2$<;b0-#r1j1_9?BmPY(i; z+upvW_sfKmuJWznwH#@}9!|$pC1A>4Fc_-oWZ*^=3Z!`+=G&}qC)Fqz4~q9nV>@CZ zU;`sh%d|(kXMjyAkNhI(#kBJ4j+udg7Kp2=u*vMZlf5LkJ_*EYY9jOJBu6Taz$qiRcrC zEJNosWmeLKijd)2YiUjJZQD0CbURLkBB93Wl?YN+;Mzy%Jxik`L$rRkO@(H6m14`X zoc#QZN~r7Gg*VKFq-Wivj2d0gb}-_TuQVqo6jOdRlSahdcNlKl|p4Zgz%UlbU zDHT2-3dp~wlEdDMvCVk2MJ;LEIKswHe3#bjE?*L!zu@UKxbV7u*a`RI*bI*ClVown zJeU_Lle0stb6`wM3NgOV&S&y(L~%3-;_#r!)8dRQpDywYNUpzKa&o7YzkF$K%6B>_ zL;bg|$_I2=>oUhX*5A%4@skVFqwP6PiN>VH8?ZRGKD!}rM6}Yo5z4nFLii zroy_zLnKA~Ros_8-^un@@XZ#Axh;?a2n3#tzJ+<`IZB6mPu7oGAZz`Lzy@p_Aq+-@ zBY^z(EBkGV>t2L=H$o610f8(C$;Su*LTG$0!quje@&5HsbG`!XOyNR-lr$B1&zf|& zHnd!Y&CT;t?=+N<=O|&E+bh!wub<>ibGC$+A~0KXw?&@2H?)KZZe*Xbz~}midObe( z7z7Zqfj|X>0=a|$4I<8j20`wnK#0IZL=+$tGPjy+2|Ns?A*B!u)(T#y0fR|MK+wQw z7!{O)6aptEWh8=|z!;(Qdl7O*N;OM_!xd*2q=O}lnLtm3L^4JieP?&1o23Ji>x_e~ zC+q-}b}yZhkxT_?1GqRl*nCZ*`jWIi1@bM08_MG5A87+}EdpVW=xQbXiUxglK zp@GUk#l%iRVdCNvQs-G{#3iB9FzG*{Kd3kGcPqZXmj6Y)0h=!s4+3-Tw=tLm1PKDu z5ZVJwP80+NgL+VG#6yi#yoH~dtVXbXe2R*%5i^{lyQJZnQ>b@F z2cwX+lNJ%RVW>e~Rb4#CI*f+|wo$)T??(*QmGhos(*hUs*)STShvHj~d1?);+Buri z1e!KiydrxsdI~O1U+l@Z#r+R!VU3lPAWzByc7SKgg3wDPjR0 zbDBHir;iYUA&&!hpn;oEPJ;Jv(h@ThGijND&L{{7Y39)flRR-_%cXb~P7e)i*?Z1I z99RnttPc2Lp47m^CxLNayaD*%xbffi2H*#79JH_FQSbd3Mq&~u1PtEY?;?b5NN^D_ z$U8qae8#9=h2%7AXMavU*gVwZyg| zZb-mLc)2yhrACDWFKtHmaP~qS$6MB7I3CxEaKEP+ScBl7TF42R(p33^ zlcZi2C8}PpWf?Y>A81$(^wu7kPp7T|+*tg*4cQdbR=CLkmn%p;{hRNr&IgnGE*lEZ z9v#(qg*Z{bJbBYPz^JPpI+uZQJfz+2L3u6*U=M0Tg=xWL)Of3i!CMT>vPNfV?e(b% z0!9!^5Y57T_1@HP?_ebiljH=&+*3^uA@E8ylf13ebgM-V2?sC5Uq-!15j1g5$WjF8 zQWU0DVZA-OQGu$PNBtt6ltrU+$cRQ>P*@|2K2e^}zo6xCk*@PSe-3DD5gAEKN9kGH zC3w5UF3YkIJm!=-Kr=)%^-4HTEV8U%`a;e+DMNPswDj8~^iQ0{oOr{$oyJqLmUuiqCkWpZ$CYYuJ{yRv zjIv@VJ&s&J2UMHS>uHIqzk~HvP$O_huY2Nyoij{}>gDAN-@lC3U*qa#baOMmsAl~B znz)Mhp&;8NN_4YM!`dP(6(E}V+coy~4;(o>7RC8k+8b!yBZv+s_ZyV50-I1s?*PNX$w^E}T{8|!xBYeHJu#2*&JWM5BPyj)F zH}o3*nXyY#2`5L5+$mwq=XOm__JXVnog_soJ`(hx&4eO1;A$>%hzQWI-cKgK+#105 z=J@5-0KPYehV{S6IG ziOfIUVfwwQduRB)AMQ69>4J%v_I4)z*rNKfVL{;aulp6>UZ8&e2QMJ(UhKVre*Y`J ltQn#f6Ay}P#qKMzZ^h6^mxQn#0s>JJeyV$Or<%RkzW~I2wC4Z- delta 2439 zcmaJ@2{aUJ7alt?SreZ!CF{^IG`2~$k7#C?kdQGkD3ZP*YKTeJ5@IY9hX1$A7L!IH z+bG)%lCn*-pt6j@H}-z&d|!Qk=l}0}&U?mt7NGm77p!Z+cP7kySw*OG%*XQCFsm6iwBqG zRVG(+)}6BedL>@8VZFQDnYqM_W{$(lhMNhWoa z*KC&{sYbob*ZEc^)DsnA(Xc9hYBOZT!5J)SYx32CJ5W_9x(pkaN^CA72xz~+%+)8` zf$lXb*jyB*tJ|)$+UREI|imng3!%e8~Yw)m$`>PYUL!yFogfj(i;2m!&s ztiptNE&yPb8vyuUy#)Ylcg_z!%`NO4Aoi9C$=|pn#;{QvqOS8X2hg8&hJ_u)3sg%? z2D2E=xAnPo^sirUdcv63^+_mdgd21cz8qr@PsCl%^R!wJ?}jSjZ04=zUPc{6A5h)! z--6VEz!A4SR;a8InR^;YeAE{+C%_HSOKs%()=j%vScABLK%0uiqk+U~*+{VbmM?9j zLdlBQPsXY4mF(-Q5wpK;U2H?LZH5*bVIMjcBD1?{_t6|u-2TaYv zqGYAE!+7hg@z{U31na)2&@_U{ymyU8OP1!QJr$+>4iJe!<;GY*1lz1u< zi*riQo7V7z8=I~D5Oc86t&DJre_s$sYJrG>jT(GTth$lfd8T~o0SCP%$CSX>Ub$&U z2nO@TFN&?Emm=~n%vy4=640n!$UOLKM0k+}kF`&EUCv$SfxxM$%Y0#+f-vv?lxS5p zAU#%3(5?2O_^Y?i!LK^K4r9eEZXVSGz7I2r66#pg1N^?sXhgj?L$P>r*wdTlMnt_3 zs(27{&AZ?jSZ(!jflBXurR(UmWEU>nUyZy%SjLsvWXxQTy;^+hiZ)`F~`K z|3bE%y{XQ559i*erGr!be^N4%DL$r>-Q1DN=>|wrQi?Q@%m>UQ6M&gAO^~zR9-bZ^ zQ1U$wT(j`$whrJ6kKMWv2C2~~vf7a$bn|sl`Wp%FD?JFcu3jWmN=Ju{6~r!s@zd{S zvC0V0S9l@qQ##ssFMVuD`V7rt zZk(ZchSDlMT5*1SioE1%T?dEZUuKttHF-=DVcM5a>%nkl=g9-^deaW1GSXBqjeQEf z6hL@mTh9Y!vQ&^>-n#T>F@o)OoOwBz_+n0Nb=8iR){+C+V{VoMkXxmiJ{ShLI%q}y^d(MtFu`%c4ooBJ~b%|zhx z9rVLGS5ku5;=)d2J#s6JB#o!$U)%soT3DXb4ZsTXvq@U3&4R_%cwJ~FNjGy>`4J#)I_OTQFJa+C)yKP-z|~jY#o0`#A--ef z9Vl@QntNeMU5T^xZoFf}#rUvZD6yhb{EB;-0&RG>5wGHQQ5|zHz`bH1t9SF+tZ31e zfs9*F=gKr6M7MNF2$f==AQDL53Mpn#nqA83rq9?8r%k>la@R^&fX}fQ3298XN2}%x zCjCRh>3MIOH=mzQIhZhXaPQ%cYg>bFW-@rU_7k4?k@^{9D58If990fN)Zd~`nhzxw zKRX8QL5e2bx;r}HYqVbT;zXHxQe>NmtNi7UEZ>Fkt6J_aEiSe&-1pK|l*huV=Qz`8 z)uOiR4=ep4S`?2F@owA@oy?E4vTn}CowW^?h@Mg`xE-76=A0=b`#73SXNA?6tvEew zC?-1luO4fY?^c}W(J8u13@$bNMHOTXp7$8c%Kc+Hx^eNGPo@FilL@i8ptOVe+Y zK9xYS#(g&%u*#;0sQ9(Ps*5vs^1B_&gM4VhoabuizBV0G{#S!pB2hhbF-tdpd~kv1 zz|nNz@Hy=+*_YXry`ZrIsBvSh-^g)j{Ig`cME9v-J!$pHyLGO?V~t)N=E!S<* zrB-RhzgC8yhtJN+@WW7dNE&T2L@sWr?Oo!p^q=KxXCnQu-%@^^PiVwHtG`42j&w)j eei%>ce^+k{9vZ>NFR_y&vVD$j3nrGl Date: Sun, 29 Mar 2020 17:49:51 -0500 Subject: [PATCH 02/22] add javadocs to mobile options --- .../java_client/remote/MobileOptions.java | 332 ++++++++++++++++-- 1 file changed, 302 insertions(+), 30 deletions(-) diff --git a/src/main/java/io/appium/java_client/remote/MobileOptions.java b/src/main/java/io/appium/java_client/remote/MobileOptions.java index 83f849fde..05d8d5ec2 100644 --- a/src/main/java/io/appium/java_client/remote/MobileOptions.java +++ b/src/main/java/io/appium/java_client/remote/MobileOptions.java @@ -22,6 +22,7 @@ import org.openqa.selenium.remote.CapabilityType; import java.net.URL; +import java.util.List; public abstract class MobileOptions> extends MutableCapabilities { @@ -29,171 +30,442 @@ public String getPlatformName() { return (String) getCapability(CapabilityType.PLATFORM_NAME); } + /** + * Set the url for the location of the App. + * + * @param url is a String representing the location of the App + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#APP + */ public T setApp(String url) { return amend(MobileCapabilityType.APP, url); } + /** + * Set the url for the location of the App. + * + * @param url is the URL representing the location of the App + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#APP + */ public T setApp(URL url) { return setApp(url.toString()); } + /** + * Get the app location. + * + * @return String representing app location + * @see MobileCapabilityType#APP + */ public String getApp() { return (String) getCapability(MobileCapabilityType.APP); } + /** + * Set the automation engine to use. + * + * @param name is the name of the automation engine + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#AUTOMATION_NAME + */ public T setAutomationName(String name) { return amend(MobileCapabilityType.AUTOMATION_NAME, name); } + /** + * Get the automation engine to use. + * + * @return String representing the name of the automation engine + * @see MobileCapabilityType#AUTOMATION_NAME + */ public String getAutomationName() { return (String) getCapability(MobileCapabilityType.AUTOMATION_NAME); } + /** + * Set the app to move directly into Webview context. + * + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#AUTO_WEBVIEW + */ public T setAutoWebview() { return setAutoWebview(true); } + /** + * Set whether the app moves directly into Webview context. + * + * @param bool is whether the app moves directly into Webview context. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#AUTO_WEBVIEW + */ public T setAutoWebview(boolean bool) { return amend(MobileCapabilityType.AUTO_WEBVIEW, bool); } - public boolean isAutoWebview() { + /** + * Get whether the app moves directly into Webview context. + * + * @return true if app moves directly into Webview context. + * @see MobileCapabilityType#AUTO_WEBVIEW + */ + public boolean doesAutoWebview() { return (boolean) getCapability(MobileCapabilityType.AUTO_WEBVIEW); } + /** + * Set the app to clear system files. + * + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#CLEAR_SYSTEM_FILES + */ public T setClearSystemFiles() { return setClearSystemFiles(true); } + /** + * Set whether the app clears system files. + * + * @param bool is whether the app clears system files. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#CLEAR_SYSTEM_FILES + */ public T setClearSystemFiles(boolean bool) { return amend(MobileCapabilityType.CLEAR_SYSTEM_FILES, bool); } - public boolean isClearSystemFiles() { + /** + * Get whether the app clears system files. + * + * @return true if the app clears system files. + * @see MobileCapabilityType#CLEAR_SYSTEM_FILES + */ + public boolean doesClearSystemFiles() { return (boolean) getCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES); } + /** + * Set the name of the device. + * + * @param deviceName is the name of the device. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#DEVICE_NAME + */ public T setDeviceName(String deviceName) { return amend(MobileCapabilityType.DEVICE_NAME, deviceName); } + /** + * Get the name of the device. + * + * @return String representing the name of the device. + * @see MobileCapabilityType#DEVICE_NAME + */ public String getDeviceName() { return (String) getCapability(MobileCapabilityType.DEVICE_NAME); } - public T setEnablePerformanceLogging(boolean bool) { - return amend(MobileCapabilityType.ENABLE_PERFORMANCE_LOGGING, bool); - } - + /** + * Set the app to enable performance logging. + * + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#ENABLE_PERFORMANCE_LOGGING + */ public T setEnablePerformanceLogging() { return setEnablePerformanceLogging(true); } - public boolean isEnablePerformanceLogging() { - return (boolean) getCapability(MobileCapabilityType.ENABLE_PERFORMANCE_LOGGING); + /** + * Set whether the app logs performance. + * + * @param bool is whether the app logs performance. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#ENABLE_PERFORMANCE_LOGGING + */ + public T setEnablePerformanceLogging(boolean bool) { + return amend(MobileCapabilityType.ENABLE_PERFORMANCE_LOGGING, bool); } - public T setEventTimings(boolean bool) { - return amend(MobileCapabilityType.EVENT_TIMINGS, bool); + /** + * Get the app logs performance. + * + * @return true if the app logs performance. + * @see MobileCapabilityType#ENABLE_PERFORMANCE_LOGGING + */ + public boolean isEnablePerformanceLogging() { + return (boolean) getCapability(MobileCapabilityType.ENABLE_PERFORMANCE_LOGGING); } + /** + * Set the app to report the timings for various Appium-internal events. + * + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#EVENT_TIMINGS + */ public T setEventTimings() { return setEventTimings(true); } - public boolean isEventTimings() { - return (boolean) getCapability(MobileCapabilityType.EVENT_TIMINGS); + /** + * Set whether the app reports the timings for various Appium-internal events. + * + * @param bool is whether the app enables event timings. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#EVENT_TIMINGS + */ + public T setEventTimings(boolean bool) { + return amend(MobileCapabilityType.EVENT_TIMINGS, bool); } - public T setFullReset(boolean bool) { - return amend(MobileCapabilityType.FULL_RESET, bool); + /** + * Get whether the app reports the timings for various Appium-internal events. + * + * @return true if the app reports event timings. + * @see MobileCapabilityType#EVENT_TIMINGS + */ + public boolean doesEventTimings() { + return (boolean) getCapability(MobileCapabilityType.EVENT_TIMINGS); } + /** + * Set the app to do a full reset. + * + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#FULL_RESET + */ public T setFullReset() { return setFullReset(true); } - public boolean isFullReset() { + /** + * Set whether the app does a full reset. + * + * @param bool is whether the app does a full reset. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#FULL_RESET + */ + public T setFullReset(boolean bool) { + return amend(MobileCapabilityType.FULL_RESET, bool); + } + + /** + * Get whether the app does a full reset. + * + * @return true if the app does a full reset. + * @see MobileCapabilityType#FULL_RESET + */ + public boolean doesFullReset() { return (boolean) getCapability(MobileCapabilityType.FULL_RESET); } + /** + * Set language abbreviation for use in session. + * + * @param language is the language abbreviation. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#LANGUAGE + */ public T setLanguage(String language) { return amend(MobileCapabilityType.LANGUAGE, language); } + /** + * Get language abbreviation for use in session. + * + * @return String representing the language abbreviation. + * @see MobileCapabilityType#LANGUAGE + */ public String getLanguage() { return (String) getCapability(MobileCapabilityType.LANGUAGE); } + /** + * Set locale abbreviation for use in session. + * + * @param locale is the locale abbreviation. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#LOCALE + */ public T setLocale(String locale) { return amend(MobileCapabilityType.LOCALE, locale); } + /** + * Get locale abbreviation for use in session. + * + * @return String representing the locale abbreviation. + * @see MobileCapabilityType#LOCALE + */ public String getLocale() { return (String) getCapability(MobileCapabilityType.LOCALE); } + /** + * Set the timeout for new commands. + * + * @param seconds is the number of seconds to timeout before seeing a new command. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#NEW_COMMAND_TIMEOUT + */ public T setNewCommandTimeout(int seconds) { return amend(MobileCapabilityType.NEW_COMMAND_TIMEOUT, seconds); } + /** + * Get the timeout for new commands. + * + * @return timeout before seeing a new command in seconds. + * @see MobileCapabilityType#NEW_COMMAND_TIMEOUT + */ public int getNewCommandTimeout() { return (int) getCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT); } - public T setNoReset(boolean bool) { - return amend(MobileCapabilityType.NO_RESET, bool); - } - + /** + * Set the app not to do a reset. + * + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#NO_RESET + */ public T setNoReset() { return setNoReset(true); } - public boolean isNoReset() { + /** + * Set whether the app does not do a reset. + * + * @param bool is whether the app does not do a reset. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#NO_RESET + */ + public T setNoReset(boolean bool) { + return amend(MobileCapabilityType.NO_RESET, bool); + } + + /** + * Get whether the app does not do a reset. + * + * @return true if the app does not do a reset. + * @see MobileCapabilityType#NO_RESET + */ + public boolean doesNoReset() { return (boolean) getCapability(MobileCapabilityType.NO_RESET); } + /** + * Set the orientation of the screen. + * + * @param orientation is the screen orientation. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#ORIENTATION + */ public T setOrientation(ScreenOrientation orientation) { return amend(MobileCapabilityType.ORIENTATION, orientation); } + /** + * Get the orientation of the screen. + * + * @return ScreenOrientation of the app. + * @see MobileCapabilityType#ORIENTATION + */ public ScreenOrientation getOrientation() { return (ScreenOrientation) getCapability(MobileCapabilityType.ORIENTATION); } - // TODO: add new method for List - public T setOtherApps(String app) { - return amend(MobileCapabilityType.OTHER_APPS, app); - } - - public String getOtherApps() { - return (String) getCapability(MobileCapabilityType.OTHER_APPS); - } - + /** + * Set the location of the app(s) to install before running a test. + * + * TODO: Consider supporting String as well as List since, but any String value can be put into a List of one + * + * @param apps is the apps to install. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#OTHER_APPS + */ + public T setOtherApps(List apps) { + return amend(MobileCapabilityType.OTHER_APPS, apps); + } + + /** + * Get the list of apps to install before running a test. + * + * @return List of apps to install. + * @see MobileCapabilityType#OTHER_APPS + */ + public List getOtherApps() { + return (List) getCapability(MobileCapabilityType.OTHER_APPS); + } + + /** + * Set the version of the platform. + * + * @param version is the platform version. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#PLATFORM_VERSION + */ public T setPlatformVersion(String version) { return amend(MobileCapabilityType.PLATFORM_VERSION, version); } + /** + * Get the version of the platform. + * + * @return String representing the platform version. + * @see MobileCapabilityType#PLATFORM_VERSION + */ public String getPlatformVersion() { return (String) getCapability(MobileCapabilityType.PLATFORM_VERSION); } + /** + * Set the app to print page source when a find operation fails. + * + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#PRINT_PAGE_SOURCE_ON_FIND_FAILURE + */ public T setPrintPageSourceOnFindFailure() { return setPrintPageSourceOnFindFailure(true); } + /** + * Set whether the app to print page source when a find operation fails. + * + * @param bool is whether to print page source. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#PRINT_PAGE_SOURCE_ON_FIND_FAILURE + */ public T setPrintPageSourceOnFindFailure(boolean bool) { return amend(MobileCapabilityType.PRINT_PAGE_SOURCE_ON_FIND_FAILURE, bool); } - public boolean isPrintPageSourceOnFindFailure() { + /** + * Get whether the app to print page source when a find operation fails. + * + * @return true if app prints page source. + * @see MobileCapabilityType#PRINT_PAGE_SOURCE_ON_FIND_FAILURE + */ + public boolean doesPrintPageSourceOnFindFailure() { return (boolean) getCapability(MobileCapabilityType.PRINT_PAGE_SOURCE_ON_FIND_FAILURE); } + /** + * Set the id of the device. + * + * @param id is the unique device identifier. + * @return this MobileOptions, for chaining. + * @see MobileCapabilityType#UDID + */ public T setUdid(String id) { return amend(MobileCapabilityType.UDID, id); } + /** + * Get the id of the device. + * + * @return String representing the unique device identifier. + * @see MobileCapabilityType#UDID + */ public String getUdid() { return (String) getCapability(MobileCapabilityType.UDID); } From e8f4cfd86334f92cf0d0cd9c0c81b172ee03aa4e Mon Sep 17 00:00:00 2001 From: titusfortner Date: Sun, 29 Mar 2020 20:26:37 -0500 Subject: [PATCH 03/22] allow MobileOptions to be instantiated --- .../android/AndroidMobileOptions.java | 3 +- .../java_client/ios/IOSMobileOptions.java | 3 +- .../java_client/remote/MobileOptions.java | 42 ++++++- .../android/AndroidOptionsTest.java | 70 +---------- .../java_client/ios/IOSOptionsTest.java | 70 +---------- .../java_client/remote/MobileOptionsTest.java | 111 ++++++++++++++++++ 6 files changed, 151 insertions(+), 148 deletions(-) create mode 100644 src/test/java/io/appium/java_client/remote/MobileOptionsTest.java diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index 79420244c..8229a1cef 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -19,11 +19,10 @@ import io.appium.java_client.remote.MobileOptions; import io.appium.java_client.remote.MobilePlatform; import org.openqa.selenium.Capabilities; -import org.openqa.selenium.remote.CapabilityType; public class AndroidMobileOptions extends MobileOptions { public AndroidMobileOptions() { - setCapability(CapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID); + setPlatformName(MobilePlatform.ANDROID); } public AndroidMobileOptions(Capabilities source) { diff --git a/src/main/java/io/appium/java_client/ios/IOSMobileOptions.java b/src/main/java/io/appium/java_client/ios/IOSMobileOptions.java index e9744246b..e419767ca 100644 --- a/src/main/java/io/appium/java_client/ios/IOSMobileOptions.java +++ b/src/main/java/io/appium/java_client/ios/IOSMobileOptions.java @@ -19,11 +19,10 @@ import io.appium.java_client.remote.MobileOptions; import io.appium.java_client.remote.MobilePlatform; import org.openqa.selenium.Capabilities; -import org.openqa.selenium.remote.CapabilityType; public class IOSMobileOptions extends MobileOptions { public IOSMobileOptions() { - setCapability(CapabilityType.PLATFORM_NAME, MobilePlatform.IOS); + setPlatformName(MobilePlatform.IOS); } public IOSMobileOptions(Capabilities source) { diff --git a/src/main/java/io/appium/java_client/remote/MobileOptions.java b/src/main/java/io/appium/java_client/remote/MobileOptions.java index 05d8d5ec2..95b0c04cf 100644 --- a/src/main/java/io/appium/java_client/remote/MobileOptions.java +++ b/src/main/java/io/appium/java_client/remote/MobileOptions.java @@ -24,8 +24,40 @@ import java.net.URL; import java.util.List; -public abstract class MobileOptions> extends MutableCapabilities { +public class MobileOptions> extends MutableCapabilities { + /** + * Creates new instance with no preset capabilities. + */ + public MobileOptions() { + } + + /** + * Creates new instance with provided capabilities capabilities. + * + * @param source is Capabilities instance to merge into new instance + */ + public MobileOptions(Capabilities source) { + merge(source); + } + + /** + * Set the Platform Name. + * + * @param platform the name of the platform. + * @return this MobileOptions, for chaining. + * @see org.openqa.selenium.remote.CapabilityType#PLATFORM_NAME + */ + public T setPlatformName(String platform) { + return amend(CapabilityType.PLATFORM_NAME, platform); + } + + /** + * Get the Platform Name. + * + * @return String representing PLATFORM_NAME + * @see org.openqa.selenium.remote.CapabilityType#PLATFORM_NAME + */ public String getPlatformName() { return (String) getCapability(CapabilityType.PLATFORM_NAME); } @@ -377,8 +409,6 @@ public ScreenOrientation getOrientation() { /** * Set the location of the app(s) to install before running a test. * - * TODO: Consider supporting String as well as List since, but any String value can be put into a List of one - * * @param apps is the apps to install. * @return this MobileOptions, for chaining. * @see MobileCapabilityType#OTHER_APPS @@ -390,11 +420,11 @@ public T setOtherApps(List apps) { /** * Get the list of apps to install before running a test. * - * @return List of apps to install. + * @return apps to install. * @see MobileCapabilityType#OTHER_APPS */ - public List getOtherApps() { - return (List) getCapability(MobileCapabilityType.OTHER_APPS); + public Object getOtherApps() { + return getCapability(MobileCapabilityType.OTHER_APPS); } /** diff --git a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java index 2765155e0..27b6502d6 100644 --- a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java +++ b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java @@ -16,16 +16,11 @@ package io.appium.java_client.android; -import io.appium.java_client.remote.AutomationName; import io.appium.java_client.remote.MobilePlatform; import org.junit.Test; import org.openqa.selenium.MutableCapabilities; -import org.openqa.selenium.ScreenOrientation; -import java.net.MalformedURLException; -import java.net.URL; - -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class AndroidOptionsTest { private AndroidMobileOptions androidMobileOptions = new AndroidMobileOptions(); @@ -48,67 +43,4 @@ public void acceptsExistingCapabilities() { assertEquals("10", androidMobileOptions.getPlatformVersion()); assertEquals(60, androidMobileOptions.getNewCommandTimeout()); } - - @Test - public void acceptsMobileCapabilities() throws MalformedURLException { - androidMobileOptions.setApp(new URL("http://example.com/myapp.apk")) - .setAutomationName(AutomationName.ANDROID_UIAUTOMATOR2) - .setPlatformVersion("10") - .setDeviceName("Pixel") - .setOtherApps("/path/to/app.apk") - .setLocale("fr_CA") - .setUdid("1ae203187fc012g") - .setOrientation(ScreenOrientation.LANDSCAPE) - .setNewCommandTimeout(60) - .setLanguage("fr"); - - assertEquals("http://example.com/myapp.apk", androidMobileOptions.getApp()); - assertEquals(AutomationName.ANDROID_UIAUTOMATOR2, androidMobileOptions.getAutomationName()); - assertEquals("10", androidMobileOptions.getPlatformVersion()); - assertEquals("Pixel", androidMobileOptions.getDeviceName()); - assertEquals("/path/to/app.apk", androidMobileOptions.getOtherApps()); - assertEquals("fr_CA", androidMobileOptions.getLocale()); - assertEquals("1ae203187fc012g", androidMobileOptions.getUdid()); - assertEquals(ScreenOrientation.LANDSCAPE, androidMobileOptions.getOrientation()); - assertEquals(60, androidMobileOptions.getNewCommandTimeout()); - assertEquals("fr", androidMobileOptions.getLanguage()); - } - - @Test - public void acceptsMobileBooleanCapabilityDefaults() { - androidMobileOptions.setClearSystemFiles() - .setAutoWebview() - .setEnablePerformanceLogging() - .setEventTimings() - .setAutoWebview() - .setFullReset() - .setPrintPageSourceOnFindFailure(); - - assertTrue(androidMobileOptions.isClearSystemFiles()); - assertTrue(androidMobileOptions.isAutoWebview()); - assertTrue(androidMobileOptions.isEnablePerformanceLogging()); - assertTrue(androidMobileOptions.isEventTimings()); - assertTrue(androidMobileOptions.isAutoWebview()); - assertTrue(androidMobileOptions.isFullReset()); - assertTrue(androidMobileOptions.isPrintPageSourceOnFindFailure()); - } - - @Test - public void setsMobileBooleanCapabilities() { - androidMobileOptions.setClearSystemFiles(false) - .setAutoWebview(false) - .setEnablePerformanceLogging(false) - .setEventTimings(false) - .setAutoWebview(false) - .setFullReset(false) - .setPrintPageSourceOnFindFailure(false); - - assertFalse(androidMobileOptions.isClearSystemFiles()); - assertFalse(androidMobileOptions.isAutoWebview()); - assertFalse(androidMobileOptions.isEnablePerformanceLogging()); - assertFalse(androidMobileOptions.isEventTimings()); - assertFalse(androidMobileOptions.isAutoWebview()); - assertFalse(androidMobileOptions.isFullReset()); - assertFalse(androidMobileOptions.isPrintPageSourceOnFindFailure()); - } } diff --git a/src/test/java/io/appium/java_client/ios/IOSOptionsTest.java b/src/test/java/io/appium/java_client/ios/IOSOptionsTest.java index f08925456..a604575ff 100644 --- a/src/test/java/io/appium/java_client/ios/IOSOptionsTest.java +++ b/src/test/java/io/appium/java_client/ios/IOSOptionsTest.java @@ -16,16 +16,11 @@ package io.appium.java_client.ios; -import io.appium.java_client.remote.AutomationName; import io.appium.java_client.remote.MobilePlatform; import org.junit.Test; import org.openqa.selenium.MutableCapabilities; -import org.openqa.selenium.ScreenOrientation; -import java.net.MalformedURLException; -import java.net.URL; - -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class IOSOptionsTest { private IOSMobileOptions iosMobileOptions = new IOSMobileOptions(); @@ -48,67 +43,4 @@ public void acceptsExistingCapabilities() { assertEquals("10", iosMobileOptions.getPlatformVersion()); assertEquals(60, iosMobileOptions.getNewCommandTimeout()); } - - @Test - public void acceptsMobileCapabilities() throws MalformedURLException { - iosMobileOptions.setApp(new URL("http://example.com/myapp.apk")) - .setAutomationName(AutomationName.ANDROID_UIAUTOMATOR2) - .setPlatformVersion("10") - .setDeviceName("Pixel") - .setOtherApps("/path/to/app.apk") - .setLocale("fr_CA") - .setUdid("1ae203187fc012g") - .setOrientation(ScreenOrientation.LANDSCAPE) - .setNewCommandTimeout(60) - .setLanguage("fr"); - - assertEquals("http://example.com/myapp.apk", iosMobileOptions.getApp()); - assertEquals(AutomationName.ANDROID_UIAUTOMATOR2, iosMobileOptions.getAutomationName()); - assertEquals("10", iosMobileOptions.getPlatformVersion()); - assertEquals("Pixel", iosMobileOptions.getDeviceName()); - assertEquals("/path/to/app.apk", iosMobileOptions.getOtherApps()); - assertEquals("fr_CA", iosMobileOptions.getLocale()); - assertEquals("1ae203187fc012g", iosMobileOptions.getUdid()); - assertEquals(ScreenOrientation.LANDSCAPE, iosMobileOptions.getOrientation()); - assertEquals(60, iosMobileOptions.getNewCommandTimeout()); - assertEquals("fr", iosMobileOptions.getLanguage()); - } - - @Test - public void acceptsMobileBooleanCapabilityDefaults() { - iosMobileOptions.setClearSystemFiles() - .setAutoWebview() - .setEnablePerformanceLogging() - .setEventTimings() - .setAutoWebview() - .setFullReset() - .setPrintPageSourceOnFindFailure(); - - assertTrue(iosMobileOptions.isClearSystemFiles()); - assertTrue(iosMobileOptions.isAutoWebview()); - assertTrue(iosMobileOptions.isEnablePerformanceLogging()); - assertTrue(iosMobileOptions.isEventTimings()); - assertTrue(iosMobileOptions.isAutoWebview()); - assertTrue(iosMobileOptions.isFullReset()); - assertTrue(iosMobileOptions.isPrintPageSourceOnFindFailure()); - } - - @Test - public void setsMobileBooleanCapabilities() { - iosMobileOptions.setClearSystemFiles(false) - .setAutoWebview(false) - .setEnablePerformanceLogging(false) - .setEventTimings(false) - .setAutoWebview(false) - .setFullReset(false) - .setPrintPageSourceOnFindFailure(false); - - assertFalse(iosMobileOptions.isClearSystemFiles()); - assertFalse(iosMobileOptions.isAutoWebview()); - assertFalse(iosMobileOptions.isEnablePerformanceLogging()); - assertFalse(iosMobileOptions.isEventTimings()); - assertFalse(iosMobileOptions.isAutoWebview()); - assertFalse(iosMobileOptions.isFullReset()); - assertFalse(iosMobileOptions.isPrintPageSourceOnFindFailure()); - } } diff --git a/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java b/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java new file mode 100644 index 000000000..c7bc3ab46 --- /dev/null +++ b/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java @@ -0,0 +1,111 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.appium.java_client.remote; + +import org.junit.Test; +import org.openqa.selenium.MutableCapabilities; +import org.openqa.selenium.ScreenOrientation; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; + +import static org.junit.Assert.*; + +public class MobileOptionsTest { + private MobileOptions mobileOptions = new MobileOptions<>(); + + @Test + public void acceptsExistingCapabilities() { + MutableCapabilities capabilities = new MutableCapabilities(); + capabilities.setCapability("deviceName", "Pixel"); + capabilities.setCapability("platformVersion", "10"); + capabilities.setCapability("newCommandTimeout", 60); + + mobileOptions = new MobileOptions<>(capabilities); + + assertEquals("Pixel", mobileOptions.getDeviceName()); + assertEquals("10", mobileOptions.getPlatformVersion()); + assertEquals(60, mobileOptions.getNewCommandTimeout()); + } + + @Test + public void acceptsMobileCapabilities() throws MalformedURLException { + ArrayList paths = new ArrayList<>(); + paths.add("/path/to/app.apk"); + + mobileOptions.setApp(new URL("http://example.com/myapp.apk")) + .setAutomationName(AutomationName.ANDROID_UIAUTOMATOR2) + .setPlatformVersion("10") + .setDeviceName("Pixel") + .setOtherApps(paths) + .setLocale("fr_CA") + .setUdid("1ae203187fc012g") + .setOrientation(ScreenOrientation.LANDSCAPE) + .setNewCommandTimeout(60) + .setLanguage("fr"); + + assertEquals("http://example.com/myapp.apk", mobileOptions.getApp()); + assertEquals(AutomationName.ANDROID_UIAUTOMATOR2, mobileOptions.getAutomationName()); + assertEquals("10", mobileOptions.getPlatformVersion()); + assertEquals("Pixel", mobileOptions.getDeviceName()); + assertEquals(paths, mobileOptions.getOtherApps()); + assertEquals("fr_CA", mobileOptions.getLocale()); + assertEquals("1ae203187fc012g", mobileOptions.getUdid()); + assertEquals(ScreenOrientation.LANDSCAPE, mobileOptions.getOrientation()); + assertEquals(60, mobileOptions.getNewCommandTimeout()); + assertEquals("fr", mobileOptions.getLanguage()); + } + + @Test + public void acceptsMobileBooleanCapabilityDefaults() { + mobileOptions.setClearSystemFiles() + .setAutoWebview() + .setEnablePerformanceLogging() + .setEventTimings() + .setAutoWebview() + .setFullReset() + .setPrintPageSourceOnFindFailure(); + + assertTrue(mobileOptions.doesClearSystemFiles()); + assertTrue(mobileOptions.doesAutoWebview()); + assertTrue(mobileOptions.isEnablePerformanceLogging()); + assertTrue(mobileOptions.doesEventTimings()); + assertTrue(mobileOptions.doesAutoWebview()); + assertTrue(mobileOptions.doesFullReset()); + assertTrue(mobileOptions.doesPrintPageSourceOnFindFailure()); + } + + @Test + public void setsMobileBooleanCapabilities() { + mobileOptions.setClearSystemFiles(false) + .setAutoWebview(false) + .setEnablePerformanceLogging(false) + .setEventTimings(false) + .setAutoWebview(false) + .setFullReset(false) + .setPrintPageSourceOnFindFailure(false); + + assertFalse(mobileOptions.doesClearSystemFiles()); + assertFalse(mobileOptions.doesAutoWebview()); + assertFalse(mobileOptions.isEnablePerformanceLogging()); + assertFalse(mobileOptions.doesEventTimings()); + assertFalse(mobileOptions.doesAutoWebview()); + assertFalse(mobileOptions.doesFullReset()); + assertFalse(mobileOptions.doesPrintPageSourceOnFindFailure()); + } +} From 9ce12fd5e05d9fe7463ea7dd85cf5bfc57c8445f Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 30 Mar 2020 11:41:08 -0500 Subject: [PATCH 04/22] make requested changes --- .../java_client/remote/MobileOptions.java | 36 ++++++++++--------- .../java_client/ios/IOSOptionsTest.java | 6 ++-- .../java_client/remote/MobileOptionsTest.java | 9 ++--- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/main/java/io/appium/java_client/remote/MobileOptions.java b/src/main/java/io/appium/java_client/remote/MobileOptions.java index 95b0c04cf..56ce8a362 100644 --- a/src/main/java/io/appium/java_client/remote/MobileOptions.java +++ b/src/main/java/io/appium/java_client/remote/MobileOptions.java @@ -22,6 +22,7 @@ import org.openqa.selenium.remote.CapabilityType; import java.net.URL; +import java.time.Duration; import java.util.List; public class MobileOptions> extends MutableCapabilities { @@ -42,9 +43,9 @@ public MobileOptions(Capabilities source) { } /** - * Set the Platform Name. + * Set the kind of mobile device or emulator to use. * - * @param platform the name of the platform. + * @param platform the kind of mobile device or emulator to use. * @return this MobileOptions, for chaining. * @see org.openqa.selenium.remote.CapabilityType#PLATFORM_NAME */ @@ -53,9 +54,9 @@ public T setPlatformName(String platform) { } /** - * Get the Platform Name. + * Get the kind of mobile device or emulator to use. * - * @return String representing PLATFORM_NAME + * @return String representing the kind of mobile device or emulator to use. * @see org.openqa.selenium.remote.CapabilityType#PLATFORM_NAME */ public String getPlatformName() { @@ -63,18 +64,19 @@ public String getPlatformName() { } /** - * Set the url for the location of the App. + * Set the absolute local path for the location of the App. + * The or remote http URL to a {@code .ipa} file (IOS), * - * @param url is a String representing the location of the App + * @param path is a String representing the location of the App * @return this MobileOptions, for chaining. * @see MobileCapabilityType#APP */ - public T setApp(String url) { - return amend(MobileCapabilityType.APP, url); + public T setApp(String path) { + return amend(MobileCapabilityType.APP, path); } /** - * Set the url for the location of the App. + * Set the remote http URL for the location of the App. * * @param url is the URL representing the location of the App * @return this MobileOptions, for chaining. @@ -147,7 +149,7 @@ public boolean doesAutoWebview() { } /** - * Set the app to clear system files. + * Set the app to delete any generated files at the end of a session. * * @return this MobileOptions, for chaining. * @see MobileCapabilityType#CLEAR_SYSTEM_FILES @@ -157,9 +159,9 @@ public T setClearSystemFiles() { } /** - * Set whether the app clears system files. + * Set whether the app deletes generated files at the end of a session. * - * @param bool is whether the app clears system files. + * @param bool is whether the app deletes generated files at the end of a session. * @return this MobileOptions, for chaining. * @see MobileCapabilityType#CLEAR_SYSTEM_FILES */ @@ -168,9 +170,9 @@ public T setClearSystemFiles(boolean bool) { } /** - * Get whether the app clears system files. + * Get whether the app deletes generated files at the end of a session. * - * @return true if the app clears system files. + * @return true if the app deletes generated files at the end of a session. * @see MobileCapabilityType#CLEAR_SYSTEM_FILES */ public boolean doesClearSystemFiles() { @@ -340,7 +342,7 @@ public String getLocale() { * @return this MobileOptions, for chaining. * @see MobileCapabilityType#NEW_COMMAND_TIMEOUT */ - public T setNewCommandTimeout(int seconds) { + public T setNewCommandTimeout(Duration seconds) { return amend(MobileCapabilityType.NEW_COMMAND_TIMEOUT, seconds); } @@ -350,8 +352,8 @@ public T setNewCommandTimeout(int seconds) { * @return timeout before seeing a new command in seconds. * @see MobileCapabilityType#NEW_COMMAND_TIMEOUT */ - public int getNewCommandTimeout() { - return (int) getCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT); + public Duration getNewCommandTimeout() { + return (Duration) getCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT); } /** diff --git a/src/test/java/io/appium/java_client/ios/IOSOptionsTest.java b/src/test/java/io/appium/java_client/ios/IOSOptionsTest.java index a604575ff..94ea95f8c 100644 --- a/src/test/java/io/appium/java_client/ios/IOSOptionsTest.java +++ b/src/test/java/io/appium/java_client/ios/IOSOptionsTest.java @@ -20,6 +20,8 @@ import org.junit.Test; import org.openqa.selenium.MutableCapabilities; +import java.time.Duration; + import static org.junit.Assert.assertEquals; public class IOSOptionsTest { @@ -35,12 +37,12 @@ public void acceptsExistingCapabilities() { MutableCapabilities capabilities = new MutableCapabilities(); capabilities.setCapability("deviceName", "Pixel"); capabilities.setCapability("platformVersion", "10"); - capabilities.setCapability("newCommandTimeout", 60); + capabilities.setCapability("newCommandTimeout", Duration.ofSeconds(60)); iosMobileOptions = new IOSMobileOptions(capabilities); assertEquals("Pixel", iosMobileOptions.getDeviceName()); assertEquals("10", iosMobileOptions.getPlatformVersion()); - assertEquals(60, iosMobileOptions.getNewCommandTimeout()); + assertEquals(Duration.ofSeconds(60), iosMobileOptions.getNewCommandTimeout()); } } diff --git a/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java b/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java index c7bc3ab46..36fc1cd28 100644 --- a/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java +++ b/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java @@ -22,6 +22,7 @@ import java.net.MalformedURLException; import java.net.URL; +import java.time.Duration; import java.util.ArrayList; import static org.junit.Assert.*; @@ -34,13 +35,13 @@ public void acceptsExistingCapabilities() { MutableCapabilities capabilities = new MutableCapabilities(); capabilities.setCapability("deviceName", "Pixel"); capabilities.setCapability("platformVersion", "10"); - capabilities.setCapability("newCommandTimeout", 60); + capabilities.setCapability("newCommandTimeout", Duration.ofSeconds(60)); mobileOptions = new MobileOptions<>(capabilities); assertEquals("Pixel", mobileOptions.getDeviceName()); assertEquals("10", mobileOptions.getPlatformVersion()); - assertEquals(60, mobileOptions.getNewCommandTimeout()); + assertEquals(Duration.ofSeconds(60), mobileOptions.getNewCommandTimeout()); } @Test @@ -56,7 +57,7 @@ public void acceptsMobileCapabilities() throws MalformedURLException { .setLocale("fr_CA") .setUdid("1ae203187fc012g") .setOrientation(ScreenOrientation.LANDSCAPE) - .setNewCommandTimeout(60) + .setNewCommandTimeout(Duration.ofSeconds(60)) .setLanguage("fr"); assertEquals("http://example.com/myapp.apk", mobileOptions.getApp()); @@ -67,7 +68,7 @@ public void acceptsMobileCapabilities() throws MalformedURLException { assertEquals("fr_CA", mobileOptions.getLocale()); assertEquals("1ae203187fc012g", mobileOptions.getUdid()); assertEquals(ScreenOrientation.LANDSCAPE, mobileOptions.getOrientation()); - assertEquals(60, mobileOptions.getNewCommandTimeout()); + assertEquals(Duration.ofSeconds(60), mobileOptions.getNewCommandTimeout()); assertEquals("fr", mobileOptions.getLanguage()); } From 59940a904c422c427865046b7a9508e1394c0080 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 30 Mar 2020 15:59:22 -0500 Subject: [PATCH 05/22] implement android options with tests --- .../android/AndroidMobileOptions.java | 637 ++++++++++++++++++ .../android/AndroidOptionsTest.java | 262 ++++++- 2 files changed, 896 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index 8229a1cef..24d3232f6 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -16,9 +16,14 @@ package io.appium.java_client.android; +import io.appium.java_client.remote.AndroidMobileCapabilityType; import io.appium.java_client.remote.MobileOptions; import io.appium.java_client.remote.MobilePlatform; import org.openqa.selenium.Capabilities; +import org.openqa.selenium.chrome.ChromeOptions; + +import java.time.Duration; +import java.util.List; public class AndroidMobileOptions extends MobileOptions { public AndroidMobileOptions() { @@ -29,4 +34,636 @@ public AndroidMobileOptions(Capabilities source) { this(); merge(source); } + + public AndroidMobileOptions setAdbExecTimeout(Duration ms) { + return amend(AndroidMobileCapabilityType.ADB_EXEC_TIMEOUT, ms); + } + + public Duration getAdbExecTimeout() { + return (Duration) getCapability(AndroidMobileCapabilityType.ADB_EXEC_TIMEOUT); + } + + public AndroidMobileOptions setAdbPort(String port) { + return amend(AndroidMobileCapabilityType.ADB_PORT, port); + } + + public String getAdbPort() { + return (String) getCapability(AndroidMobileCapabilityType.ADB_PORT); + } + + public AndroidMobileOptions setAllowTestPackages() { + return setAllowTestPackages(true); + } + + public AndroidMobileOptions setAllowTestPackages(boolean bool) { + return amend(AndroidMobileCapabilityType.ALLOW_TEST_PACKAGES, bool); + } + + public boolean doesAllowTestPackages() { + return (boolean) getCapability(AndroidMobileCapabilityType.ALLOW_TEST_PACKAGES); + } + + public AndroidMobileOptions setAndroidCoverage(String coverage) { + return amend(AndroidMobileCapabilityType.ANDROID_COVERAGE, coverage); + } + + public String getAndroidCoverage() { + return (String) getCapability(AndroidMobileCapabilityType.ANDROID_COVERAGE); + } + + public AndroidMobileOptions setAndroidCoverageEndIntent(String coverage) { + return amend(AndroidMobileCapabilityType.ANDROID_COVERAGE_END_INTENT, coverage); + } + + public String getAndroidCoverageEndIntent() { + return (String) getCapability(AndroidMobileCapabilityType.ANDROID_COVERAGE_END_INTENT); + } + + public AndroidMobileOptions setAndroidDeviceReadyTimeout(Duration seconds) { + return amend(AndroidMobileCapabilityType.ANDROID_DEVICE_READY_TIMEOUT, seconds); + } + + public Duration getAndroidDeviceReadyTimeout() { + return (Duration) getCapability(AndroidMobileCapabilityType.ANDROID_DEVICE_READY_TIMEOUT); + } + + public AndroidMobileOptions setAndroidDeviceSocket(String activity) { + return amend(AndroidMobileCapabilityType.ANDROID_DEVICE_SOCKET, activity); + } + + public String getAndroidDeviceSocket() { + return (String) getCapability(AndroidMobileCapabilityType.ANDROID_DEVICE_SOCKET); + } + + public AndroidMobileOptions setAndroidInstallPath(String path) { + return amend(AndroidMobileCapabilityType.ANDROID_INSTALL_PATH, path); + } + + public String getAndroidInstallPath() { + return (String) getCapability(AndroidMobileCapabilityType.ANDROID_INSTALL_PATH); + } + + public AndroidMobileOptions setAndroidInstallTimeout(Duration ms) { + return amend(AndroidMobileCapabilityType.ANDROID_INSTALL_TIMEOUT, ms); + } + + public Duration getAndroidInstallTimeout() { + return (Duration) getCapability(AndroidMobileCapabilityType.ANDROID_INSTALL_TIMEOUT); + } + + public AndroidMobileOptions setAndroidNaturalOrientation() { + return setAndroidNaturalOrientation(true); + } + + public AndroidMobileOptions setAndroidNaturalOrientation(boolean bool) { + return amend(AndroidMobileCapabilityType.ANDROID_NATURAL_ORIENTATION, bool); + } + + public boolean isAndroidNaturalOrientation() { + return (boolean) getCapability(AndroidMobileCapabilityType.ANDROID_NATURAL_ORIENTATION); + } + + public AndroidMobileOptions setAndroidScreenshotPath(String path) { + return amend(AndroidMobileCapabilityType.ANDROID_SCREENSHOT_PATH, path); + } + + public String getAndroidScreenshotPath() { + return (String) getCapability(AndroidMobileCapabilityType.ANDROID_SCREENSHOT_PATH); + } + + public AndroidMobileOptions setAppActivity(String activity) { + return amend(AndroidMobileCapabilityType.APP_ACTIVITY, activity); + } + + public String getAppActivity() { + return (String) getCapability(AndroidMobileCapabilityType.APP_ACTIVITY); + } + + public AndroidMobileOptions setAppPackage(String pkg) { + return amend(AndroidMobileCapabilityType.APP_PACKAGE, pkg); + } + + public String getAppPackage() { + return (String) getCapability(AndroidMobileCapabilityType.APP_PACKAGE); + } + + public AndroidMobileOptions setAppWaitActivity(String activity) { + return amend(AndroidMobileCapabilityType.APP_WAIT_ACTIVITY, activity); + } + + public String getAppWaitActivity() { + return (String) getCapability(AndroidMobileCapabilityType.APP_WAIT_ACTIVITY); + } + + public AndroidMobileOptions setAppWaitDuration(Duration ms) { + return amend(AndroidMobileCapabilityType.APP_WAIT_DURATION, ms); + } + + public Duration getAppWaitDuration() { + return (Duration) getCapability(AndroidMobileCapabilityType.APP_WAIT_DURATION); + } + + public AndroidMobileOptions setAppWaitPackage(String pkg) { + return amend(AndroidMobileCapabilityType.APP_WAIT_PACKAGE, pkg); + } + + public String getAppWaitPackage() { + return (String) getCapability(AndroidMobileCapabilityType.APP_WAIT_PACKAGE); + } + + public AndroidMobileOptions setAutoGrantPermissions() { + return setAutoGrantPermissions(true); + } + + public AndroidMobileOptions setAutoGrantPermissions(boolean bool) { + return amend(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, bool); + } + + public boolean doesAutoGrantPermissions() { + return (boolean) getCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS); + } + + public AndroidMobileOptions setAutoLaunch() { + return setAutoLaunch(true); + } + + public AndroidMobileOptions setAutoLaunch(boolean bool) { + return amend(AndroidMobileCapabilityType.AUTO_LAUNCH, bool); + } + + public boolean doesAutoLaunch() { + return (boolean) getCapability(AndroidMobileCapabilityType.AUTO_LAUNCH); + } + + public AndroidMobileOptions setAutoWebviewTimeout(Duration ms) { + return amend(AndroidMobileCapabilityType.AUTO_WEBVIEW_TIMEOUT, ms); + } + + public Duration getAutoWebviewTimeout() { + return (Duration) getCapability(AndroidMobileCapabilityType.AUTO_WEBVIEW_TIMEOUT); + } + + public AndroidMobileOptions setAvd(String name) { + return amend(AndroidMobileCapabilityType.AVD, name); + } + + public String getAvd() { + return (String) getCapability(AndroidMobileCapabilityType.AVD); + } + + public AndroidMobileOptions setAvdArgs(String args) { + return amend(AndroidMobileCapabilityType.AVD_ARGS, args); + } + + public String getAvdArgs() { + return (String) getCapability(AndroidMobileCapabilityType.AVD_ARGS); + } + + public AndroidMobileOptions setAvdLaunchTimeout(Duration ms) { + return amend(AndroidMobileCapabilityType.AVD_LAUNCH_TIMEOUT, ms); + } + + public Duration getAvdLaunchTimeout() { + return (Duration) getCapability(AndroidMobileCapabilityType.AVD_LAUNCH_TIMEOUT); + } + + public AndroidMobileOptions setAvdReadyTimeout(Duration ms) { + return amend(AndroidMobileCapabilityType.AVD_READY_TIMEOUT, ms); + } + + public Duration getAvdReadyTimeout() { + return (Duration) getCapability(AndroidMobileCapabilityType.AVD_READY_TIMEOUT); + } + + public AndroidMobileOptions setBuildToolsVersion(String pkg) { + return amend(AndroidMobileCapabilityType.BUILD_TOOLS_VERSION, pkg); + } + + public String getBuildToolsVersion() { + return (String) getCapability(AndroidMobileCapabilityType.BUILD_TOOLS_VERSION); + } + + public AndroidMobileOptions setChromedriverArgs(List args) { + return amend(AndroidMobileCapabilityType.CHROMEDRIVER_ARGS, args); + } + + public Object getChromedriverArgs() { + return getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_ARGS); + } + + public AndroidMobileOptions setChromedriverChromeMappingFile(String path) { + return amend(AndroidMobileCapabilityType.CHROMEDRIVER_CHROME_MAPPING_FILE, path); + } + + public String getChromedriverChromeMappingFile() { + return (String) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_CHROME_MAPPING_FILE); + } + + public AndroidMobileOptions setChromedriverDisableBuildCheck() { + return setChromedriverDisableBuildCheck(true); + } + + public AndroidMobileOptions setChromedriverDisableBuildCheck(boolean bool) { + return amend(AndroidMobileCapabilityType.CHROMEDRIVER_DISABLE_BUILD_CHECK, bool); + } + + public boolean doesChromedriverDisableBuildCheck() { + return (boolean) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_DISABLE_BUILD_CHECK); + } + + public AndroidMobileOptions setChromedriverExecutable(String path) { + return amend(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE, path); + } + + public String getChromedriverExecutable() { + return (String) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE); + } + + public AndroidMobileOptions setChromedriverExecutableDir(String dir) { + return amend(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE_DIR, dir); + } + + public String getChromedriverExecutableDir() { + return (String) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE_DIR); + } + + public AndroidMobileOptions setChromedriverPort(int port) { + return amend(AndroidMobileCapabilityType.CHROMEDRIVER_PORT, port); + } + + public int getChromedriverPort() { + return (int) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_PORT); + } + + public AndroidMobileOptions setChromedriverPorts(List ports) { + return amend(AndroidMobileCapabilityType.BUILD_TOOLS_VERSION, ports); + } + + public Object getChromedriverPorts() { + return getCapability(AndroidMobileCapabilityType.BUILD_TOOLS_VERSION); + } + + public AndroidMobileOptions setChromedriverUseSystemExecutable() { + return setChromedriverUseSystemExecutable(true); + } + + public AndroidMobileOptions setChromedriverUseSystemExecutable(boolean bool) { + return amend(AndroidMobileCapabilityType.CHROMEDRIVER_DISABLE_BUILD_CHECK, bool); + } + + public boolean doesChromedriverUseSystemExecutable() { + return (boolean) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_DISABLE_BUILD_CHECK); + } + + public AndroidMobileOptions setChromeOptions(ChromeOptions opts) { + return amend(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE_DIR, opts); + } + + public Object getChromeOptions() { + return getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE_DIR); + } + + public AndroidMobileOptions setDeviceReadyTimeout(Duration seconds) { + return amend(AndroidMobileCapabilityType.DEVICE_READY_TIMEOUT, seconds); + } + + public Duration getDeviceReadyTimeout() { + return (Duration) getCapability(AndroidMobileCapabilityType.DEVICE_READY_TIMEOUT); + } + + public AndroidMobileOptions setDisableAndroidWatchers() { + return setDisableAndroidWatchers(true); + } + + public AndroidMobileOptions setDisableAndroidWatchers(boolean bool) { + return amend(AndroidMobileCapabilityType.DISABLE_ANDROID_WATCHERS, bool); + } + + public boolean doesDisableAndroidWatchers() { + return (boolean) getCapability(AndroidMobileCapabilityType.DISABLE_ANDROID_WATCHERS); + } + + public AndroidMobileOptions setDisableWindowAnimation() { + return setDisableWindowAnimation(true); + } + + public AndroidMobileOptions setDisableWindowAnimation(boolean bool) { + return amend(AndroidMobileCapabilityType.DISABLE_WINDOW_ANIMATION, bool); + } + + public boolean doesDisableWindowAnimation() { + return (boolean) getCapability(AndroidMobileCapabilityType.DISABLE_WINDOW_ANIMATION); + } + + public AndroidMobileOptions setDontStopAppOnReset() { + return setDontStopAppOnReset(true); + } + + public AndroidMobileOptions setDontStopAppOnReset(boolean bool) { + return amend(AndroidMobileCapabilityType.DONT_STOP_APP_ON_RESET, bool); + } + + public boolean isDontStopAppOnReset() { + return (boolean) getCapability(AndroidMobileCapabilityType.DONT_STOP_APP_ON_RESET); + } + + public AndroidMobileOptions setEnforceAppInstall() { + return setEnforceAppInstall(true); + } + + public AndroidMobileOptions setEnforceAppInstall(boolean bool) { + return amend(AndroidMobileCapabilityType.ENFORCE_APP_INSTALL, bool); + } + + public boolean doesEnforceAppInstall() { + return (boolean) getCapability(AndroidMobileCapabilityType.ENFORCE_APP_INSTALL); + } + + public AndroidMobileOptions setEnsureWebviewsHavePages() { + return setEnsureWebviewsHavePages(true); + } + + public AndroidMobileOptions setEnsureWebviewsHavePages(boolean bool) { + return amend(AndroidMobileCapabilityType.ENSURE_WEBVIEWS_HAVE_PAGES, bool); + } + + public boolean doesEnsureWebviewsHavePages() { + return (boolean) getCapability(AndroidMobileCapabilityType.ENSURE_WEBVIEWS_HAVE_PAGES); + } + + public AndroidMobileOptions setGpsEnabled() { + return setGpsEnabled(true); + } + + public AndroidMobileOptions setGpsEnabled(boolean bool) { + return amend(AndroidMobileCapabilityType.GPS_ENABLED, bool); + } + + public boolean isGpsEnabled() { + return (boolean) getCapability(AndroidMobileCapabilityType.GPS_ENABLED); + } + + public AndroidMobileOptions setIgnoreUnimportantViews() { + return setIgnoreUnimportantViews(true); + } + + public AndroidMobileOptions setIgnoreUnimportantViews(boolean bool) { + return amend(AndroidMobileCapabilityType.IGNORE_UNIMPORTANT_VIEWS, bool); + } + + public boolean doesIgnoreUnimportantViews() { + return (boolean) getCapability(AndroidMobileCapabilityType.IGNORE_UNIMPORTANT_VIEWS); + } + + public AndroidMobileOptions setIntentAction(String action) { + return amend(AndroidMobileCapabilityType.INTENT_ACTION, action); + } + + public String getIntentAction() { + return (String) getCapability(AndroidMobileCapabilityType.INTENT_ACTION); + } + + public AndroidMobileOptions setIntentCategory(String category) { + return amend(AndroidMobileCapabilityType.INTENT_CATEGORY, category); + } + + public String getIntentCategory() { + return (String) getCapability(AndroidMobileCapabilityType.INTENT_CATEGORY); + } + + public AndroidMobileOptions setIntentFlags(String category) { + return amend(AndroidMobileCapabilityType.INTENT_FLAGS, category); + } + + public String getIntentFlags() { + return (String) getCapability(AndroidMobileCapabilityType.INTENT_FLAGS); + } + + public AndroidMobileOptions setIsHeadless(boolean bool) { + return amend(AndroidMobileCapabilityType.IS_HEADLESS, bool); + } + + public boolean isHeadless() { + return (boolean) getCapability(AndroidMobileCapabilityType.IS_HEADLESS); + } + + public AndroidMobileOptions setKeyAlias(String alias) { + return amend(AndroidMobileCapabilityType.KEY_ALIAS, alias); + } + + public String getKeyAlias() { + return (String) getCapability(AndroidMobileCapabilityType.KEY_ALIAS); + } + + public AndroidMobileOptions setKeyPassword(String password) { + return amend(AndroidMobileCapabilityType.KEY_PASSWORD, password); + } + + public String getKeyPassword() { + return (String) getCapability(AndroidMobileCapabilityType.KEY_PASSWORD); + } + + public AndroidMobileOptions setKeystorePassword(String password) { + return amend(AndroidMobileCapabilityType.KEYSTORE_PASSWORD, password); + } + + public String getKeystorePassword() { + return (String) getCapability(AndroidMobileCapabilityType.KEYSTORE_PASSWORD); + } + + public AndroidMobileOptions setKeystorePath(String path) { + return amend(AndroidMobileCapabilityType.KEYSTORE_PATH, path); + } + + public String getKeystorePath() { + return (String) getCapability(AndroidMobileCapabilityType.KEYSTORE_PATH); + } + + public AndroidMobileOptions setLocaleScript(String path) { + return amend(AndroidMobileCapabilityType.LOCALE_SCRIPT, path); + } + + public String getLocaleScript() { + return (String) getCapability(AndroidMobileCapabilityType.LOCALE_SCRIPT); + } + + public AndroidMobileOptions setNativeWebScreenshot() { + return setNativeWebScreenshot(true); + } + + public AndroidMobileOptions setNativeWebScreenshot(boolean bool) { + return amend(AndroidMobileCapabilityType.NATIVE_WEB_SCREENSHOT, bool); + } + + public boolean doesNativeWebScreenshot() { + return (boolean) getCapability(AndroidMobileCapabilityType.NATIVE_WEB_SCREENSHOT); + } + + public AndroidMobileOptions setNetworkSpeed(String speed) { + return amend(AndroidMobileCapabilityType.NETWORK_SPEED, speed); + } + + public String getNetworkSpeed() { + return (String) getCapability(AndroidMobileCapabilityType.NETWORK_SPEED); + } + + public AndroidMobileOptions setNoSign() { + return setNoSign(true); + } + + public AndroidMobileOptions setNoSign(boolean bool) { + return amend(AndroidMobileCapabilityType.NO_SIGN, bool); + } + + public boolean isNoSign() { + return (boolean) getCapability(AndroidMobileCapabilityType.NO_SIGN); + } + + public AndroidMobileOptions setOptionalIntentArguments(String speed) { + return amend(AndroidMobileCapabilityType.OPTIONAL_INTENT_ARGUMENTS, speed); + } + + public String getOptionalIntentArguments() { + return (String) getCapability(AndroidMobileCapabilityType.OPTIONAL_INTENT_ARGUMENTS); + } + + public AndroidMobileOptions setRecreateChromeDriverSessions() { + return setRecreateChromeDriverSessions(true); + } + + public AndroidMobileOptions setRecreateChromeDriverSessions(boolean bool) { + return amend(AndroidMobileCapabilityType.RECREATE_CHROME_DRIVER_SESSIONS, bool); + } + + public boolean doesRecreateChromeDriverSessions() { + return (boolean) getCapability(AndroidMobileCapabilityType.RECREATE_CHROME_DRIVER_SESSIONS); + } + + public AndroidMobileOptions setRemoteAdbHost(String host) { + return amend(AndroidMobileCapabilityType.REMOTE_ADB_HOST, host); + } + + public String getRemoteAdbHost() { + return (String) getCapability(AndroidMobileCapabilityType.REMOTE_ADB_HOST); + } + + public AndroidMobileOptions setRemoteAppsCacheLimit(int num) { + return amend(AndroidMobileCapabilityType.REMOTE_APPS_CACHE_LIMIT, num); + } + + public int getRemoteAppsCacheLimit() { + return (int) getCapability(AndroidMobileCapabilityType.REMOTE_APPS_CACHE_LIMIT); + } + + public AndroidMobileOptions setResetKeyboard() { + return setResetKeyboard(true); + } + + public AndroidMobileOptions setResetKeyboard(boolean bool) { + return amend(AndroidMobileCapabilityType.RESET_KEYBOARD, bool); + } + + public boolean doesResetKeyboard() { + return (boolean) getCapability(AndroidMobileCapabilityType.RESET_KEYBOARD); + } + + public AndroidMobileOptions setSkipDeviceInitialization() { + return setSkipDeviceInitialization(true); + } + + public AndroidMobileOptions setSkipDeviceInitialization(boolean bool) { + return amend(AndroidMobileCapabilityType.SKIP_DEVICE_INITIALIZATION, bool); + } + + public boolean doesSkipDeviceInitialization() { + return (boolean) getCapability(AndroidMobileCapabilityType.SKIP_DEVICE_INITIALIZATION); + } + + public AndroidMobileOptions setSkipLogcatCapture() { + return setSkipLogcatCapture(true); + } + + public AndroidMobileOptions setSkipLogcatCapture(boolean bool) { + return amend(AndroidMobileCapabilityType.SKIP_LOGCAT_CAPTURE, bool); + } + + public boolean doesSkipLogcatCapture() { + return (boolean) getCapability(AndroidMobileCapabilityType.SKIP_LOGCAT_CAPTURE); + } + + public AndroidMobileOptions setSkipUnlock() { + return setSkipUnlock(true); + } + + public AndroidMobileOptions setSkipUnlock(boolean bool) { + return amend(AndroidMobileCapabilityType.SKIP_UNLOCK, bool); + } + + public boolean doesSkipUnlock() { + return (boolean) getCapability(AndroidMobileCapabilityType.SKIP_UNLOCK); + } + + public AndroidMobileOptions setSystemPort(String port) { + return amend(AndroidMobileCapabilityType.SYSTEM_PORT, port); + } + + public String getSystemPort() { + return (String) getCapability(AndroidMobileCapabilityType.SYSTEM_PORT); + } + + public AndroidMobileOptions setUnicodeKeyboard() { + return setUnicodeKeyboard(true); + } + + public AndroidMobileOptions setUnicodeKeyboard(boolean bool) { + return amend(AndroidMobileCapabilityType.UNICODE_KEYBOARD, bool); + } + + public boolean isUnicodeKeyboard() { + return (boolean) getCapability(AndroidMobileCapabilityType.UNICODE_KEYBOARD); + } + + public AndroidMobileOptions setUninstallOtherPackages(List packages) { + return amend(AndroidMobileCapabilityType.UNINSTALL_OTHER_PACKAGES, packages); + } + + public Object getUninstallOtherPackages() { + return getCapability(AndroidMobileCapabilityType.UNINSTALL_OTHER_PACKAGES); + } + + public AndroidMobileOptions setUnlockKey(String key) { + return amend(AndroidMobileCapabilityType.UNLOCK_KEY, key); + } + + public String getUnlockKey() { + return (String) getCapability(AndroidMobileCapabilityType.UNLOCK_KEY); + } + + public AndroidMobileOptions setUnlockType(String type) { + return amend(AndroidMobileCapabilityType.UNLOCK_TYPE, type); + } + + public String getUnlockType() { + return (String) getCapability(AndroidMobileCapabilityType.UNLOCK_TYPE); + } + + public AndroidMobileOptions setUseKeystore() { + return setUseKeystore(true); + } + + public AndroidMobileOptions setUseKeystore(boolean bool) { + return amend(AndroidMobileCapabilityType.USE_KEYSTORE, bool); + } + + public boolean doesUseKeystore() { + return (boolean) getCapability(AndroidMobileCapabilityType.USE_KEYSTORE); + } + + public AndroidMobileOptions setWebviewDevtoolsPort(String port) { + return amend(AndroidMobileCapabilityType.WEBVIEW_DEVTOOLS_PORT, port); + } + + public String getWebviewDevtoolsPort() { + return (String) getCapability(AndroidMobileCapabilityType.WEBVIEW_DEVTOOLS_PORT); + } } diff --git a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java index 27b6502d6..afff25969 100644 --- a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java +++ b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java @@ -16,11 +16,20 @@ package io.appium.java_client.android; +import io.appium.java_client.remote.AutomationName; import io.appium.java_client.remote.MobilePlatform; import org.junit.Test; import org.openqa.selenium.MutableCapabilities; +import org.openqa.selenium.ScreenOrientation; +import org.openqa.selenium.chrome.ChromeOptions; -import static org.junit.Assert.assertEquals; +import java.net.MalformedURLException; +import java.net.URL; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; public class AndroidOptionsTest { private AndroidMobileOptions androidMobileOptions = new AndroidMobileOptions(); @@ -35,12 +44,259 @@ public void acceptsExistingCapabilities() { MutableCapabilities capabilities = new MutableCapabilities(); capabilities.setCapability("deviceName", "Pixel"); capabilities.setCapability("platformVersion", "10"); - capabilities.setCapability("newCommandTimeout", 60); + capabilities.setCapability("newCommandTimeout", Duration.ofSeconds(60)); androidMobileOptions = new AndroidMobileOptions(capabilities); assertEquals("Pixel", androidMobileOptions.getDeviceName()); assertEquals("10", androidMobileOptions.getPlatformVersion()); - assertEquals(60, androidMobileOptions.getNewCommandTimeout()); + assertEquals(Duration.ofSeconds(60), androidMobileOptions.getNewCommandTimeout()); + } + + @Test + public void acceptsMobileCapabilities() throws MalformedURLException { + ArrayList paths = new ArrayList<>(); + paths.add("/path/to/app.apk"); + + androidMobileOptions.setApp(new URL("http://example.com/myapp.apk")) + .setAutomationName(AutomationName.ANDROID_UIAUTOMATOR2) + .setPlatformVersion("10") + .setDeviceName("Pixel") + .setOtherApps(paths) + .setLocale("fr_CA") + .setUdid("1ae203187fc012g") + .setOrientation(ScreenOrientation.LANDSCAPE) + .setNewCommandTimeout(Duration.ofSeconds(60)) + .setLanguage("fr"); + + assertEquals("http://example.com/myapp.apk", androidMobileOptions.getApp()); + assertEquals(AutomationName.ANDROID_UIAUTOMATOR2, androidMobileOptions.getAutomationName()); + assertEquals("10", androidMobileOptions.getPlatformVersion()); + assertEquals("Pixel", androidMobileOptions.getDeviceName()); + assertEquals(paths, androidMobileOptions.getOtherApps()); + assertEquals("fr_CA", androidMobileOptions.getLocale()); + assertEquals("1ae203187fc012g", androidMobileOptions.getUdid()); + assertEquals(ScreenOrientation.LANDSCAPE, androidMobileOptions.getOrientation()); + assertEquals(Duration.ofSeconds(60), androidMobileOptions.getNewCommandTimeout()); + assertEquals("fr", androidMobileOptions.getLanguage()); + } + + @Test + public void acceptsChromeDriverOptions() { + androidMobileOptions = new AndroidMobileOptions(); + ChromeOptions chromeOptions = new ChromeOptions(); + androidMobileOptions.setChromeOptions(chromeOptions); + + assertEquals(chromeOptions, androidMobileOptions.getChromeOptions()); + } + + @Test + public void setsAndroidBooleanDefaultCapabilities() { + androidMobileOptions.setAllowTestPackages() + .setAndroidNaturalOrientation() + .setAutoGrantPermissions() + .setAutoLaunch() + .setChromedriverDisableBuildCheck() + .setChromedriverUseSystemExecutable() + .setDisableAndroidWatchers() + .setDisableWindowAnimation() + .setDontStopAppOnReset() + .setEnforceAppInstall() + .setEnsureWebviewsHavePages() + .setGpsEnabled() + .setIgnoreUnimportantViews() + .setNativeWebScreenshot() + .setNoSign() + .setRecreateChromeDriverSessions() + .setResetKeyboard() + .setSkipDeviceInitialization() + .setSkipLogcatCapture() + .setSkipUnlock() + .setUnicodeKeyboard() + .setUseKeystore(); + + assertTrue(androidMobileOptions.doesAllowTestPackages()); + assertTrue(androidMobileOptions.isAndroidNaturalOrientation()); + assertTrue(androidMobileOptions.doesAutoGrantPermissions()); + assertTrue(androidMobileOptions.doesAutoLaunch()); + assertTrue(androidMobileOptions.doesChromedriverDisableBuildCheck()); + assertTrue(androidMobileOptions.doesChromedriverUseSystemExecutable()); + assertTrue(androidMobileOptions.doesDisableAndroidWatchers()); + assertTrue(androidMobileOptions.doesDisableWindowAnimation()); + assertTrue(androidMobileOptions.isDontStopAppOnReset()); + assertTrue(androidMobileOptions.doesEnforceAppInstall()); + assertTrue(androidMobileOptions.doesEnsureWebviewsHavePages()); + assertTrue(androidMobileOptions.isGpsEnabled()); + assertTrue(androidMobileOptions.doesIgnoreUnimportantViews()); + assertTrue(androidMobileOptions.doesNativeWebScreenshot()); + assertTrue(androidMobileOptions.isNoSign()); + assertTrue(androidMobileOptions.doesRecreateChromeDriverSessions()); + assertTrue(androidMobileOptions.doesResetKeyboard()); + assertTrue(androidMobileOptions.doesSkipDeviceInitialization()); + assertTrue(androidMobileOptions.doesSkipLogcatCapture()); + assertTrue(androidMobileOptions.doesSkipUnlock()); + assertTrue(androidMobileOptions.isUnicodeKeyboard()); + assertTrue(androidMobileOptions.doesUseKeystore()); + } + + @Test + public void setsAndroidBooleanValueCapabilities() { + androidMobileOptions.setAllowTestPackages(false) + .setAndroidNaturalOrientation(false) + .setAutoGrantPermissions(false) + .setAutoLaunch(false) + .setChromedriverDisableBuildCheck(false) + .setChromedriverUseSystemExecutable(false) + .setDisableAndroidWatchers(false) + .setDisableWindowAnimation(false) + .setDontStopAppOnReset(false) + .setEnforceAppInstall(false) + .setEnsureWebviewsHavePages(false) + .setGpsEnabled(false) + .setIgnoreUnimportantViews(false) + .setIsHeadless(false) + .setNativeWebScreenshot(false) + .setNoSign(false) + .setRecreateChromeDriverSessions(false) + .setResetKeyboard(false) + .setSkipDeviceInitialization(false) + .setSkipLogcatCapture(false) + .setSkipUnlock(false) + .setUnicodeKeyboard(false) + .setUseKeystore(false); + + assertFalse(androidMobileOptions.doesAllowTestPackages()); + assertFalse(androidMobileOptions.isAndroidNaturalOrientation()); + assertFalse(androidMobileOptions.doesAutoGrantPermissions()); + assertFalse(androidMobileOptions.doesAutoLaunch()); + assertFalse(androidMobileOptions.doesChromedriverDisableBuildCheck()); + assertFalse(androidMobileOptions.doesChromedriverUseSystemExecutable()); + assertFalse(androidMobileOptions.doesDisableAndroidWatchers()); + assertFalse(androidMobileOptions.doesDisableWindowAnimation()); + assertFalse(androidMobileOptions.isDontStopAppOnReset()); + assertFalse(androidMobileOptions.doesEnforceAppInstall()); + assertFalse(androidMobileOptions.doesEnsureWebviewsHavePages()); + assertFalse(androidMobileOptions.isGpsEnabled()); + assertFalse(androidMobileOptions.doesIgnoreUnimportantViews()); + assertFalse(androidMobileOptions.isHeadless()); + assertFalse(androidMobileOptions.doesNativeWebScreenshot()); + assertFalse(androidMobileOptions.isNoSign()); + assertFalse(androidMobileOptions.doesRecreateChromeDriverSessions()); + assertFalse(androidMobileOptions.doesResetKeyboard()); + assertFalse(androidMobileOptions.doesSkipDeviceInitialization()); + assertFalse(androidMobileOptions.doesSkipLogcatCapture()); + assertFalse(androidMobileOptions.doesSkipUnlock()); + assertFalse(androidMobileOptions.isUnicodeKeyboard()); + assertFalse(androidMobileOptions.doesUseKeystore()); + } + + @Test + public void setsAndroidNumberCapabilities() { + List ports = new ArrayList<>(); + ports.add(9000); + ports.add(9005); + + androidMobileOptions.setAdbExecTimeout(Duration.ofMillis(500)) + .setAndroidDeviceReadyTimeout(Duration.ofSeconds(5)) + .setAndroidInstallTimeout(Duration.ofSeconds(300)) + .setAppWaitDuration(Duration.ofMillis(8000)) + .setAutoWebviewTimeout(Duration.ofMillis(9000)) + .setAvdLaunchTimeout(Duration.ofMillis(10000)) + .setAvdReadyTimeout(Duration.ofMillis(11000)) + .setChromedriverPort(1234) + .setChromedriverPorts(ports) + .setDeviceReadyTimeout(Duration.ofSeconds(33)) + .setRemoteAppsCacheLimit(4); + + assertEquals(Duration.ofMillis(500), androidMobileOptions.getAdbExecTimeout()); + assertEquals(Duration.ofSeconds(5), androidMobileOptions.getAndroidDeviceReadyTimeout()); + assertEquals(Duration.ofSeconds(300), androidMobileOptions.getAndroidInstallTimeout()); + assertEquals(Duration.ofMillis(8000), androidMobileOptions.getAppWaitDuration()); + assertEquals(Duration.ofMillis(9000), androidMobileOptions.getAutoWebviewTimeout()); + assertEquals(Duration.ofMillis(10000), androidMobileOptions.getAvdLaunchTimeout()); + assertEquals(Duration.ofMillis(11000), androidMobileOptions.getAvdReadyTimeout()); + assertEquals(1234, androidMobileOptions.getChromedriverPort()); + assertEquals(ports, androidMobileOptions.getChromedriverPorts()); + assertEquals(Duration.ofSeconds(33), androidMobileOptions.getDeviceReadyTimeout()); + assertEquals(4, androidMobileOptions.getRemoteAppsCacheLimit()); + } + + @Test + public void setsAndroidStringCapabilities() { + List chromedriverArgs = new ArrayList<>(); + chromedriverArgs.add("--disable-gpu"); + chromedriverArgs.add("--disable-web-security"); + + List uninstallPackages = new ArrayList<>(); + uninstallPackages.add("io.appium.example1"); + uninstallPackages.add("io.appium.example2"); + + androidMobileOptions.setAdbPort("1234") + .setAndroidCoverage("com.my.Pkg/com.my.Pkg.instrumentation.MyInstrumentation") + .setAndroidCoverageEndIntent("com.example.pkg.END_EMMA") + .setAndroidDeviceSocket("chrome_devtools_remote") + .setAndroidInstallPath("/sdcard/Downloads/") + .setAndroidScreenshotPath("/sdcard/screenshots/") + .setAppActivity(".MainActivity") + .setAppPackage("com.example.android.myApp") + .setAppWaitActivity("SplashActivity,OtherActivity") + .setAppWaitPackage("com.example.android.myApp") + .setAvd("api19") + .setAvdArgs("-netfast") + .setBuildToolsVersion("28.0.3") + .setChromedriverArgs(chromedriverArgs) + .setChromedriverChromeMappingFile("/abs/path/to/mapping.json") + .setChromedriverExecutable("/abs/path/to/webdriver") + .setChromedriverExecutableDir("/abs/path/to/chromedriver/directory") + .setIntentAction("android.intent.action.MAIN") + .setIntentCategory("android.intent.category.LAUNCHER") + .setIntentFlags("0x10200000") + .setKeyAlias("androiddebugkey") + .setKeyPassword("foo") + .setKeystorePassword("foo") + .setKeystorePath("/path/to.keystore") + .setLocaleScript("Cyrl") + .setNetworkSpeed("hscsd") + .setOptionalIntentArguments("--esn 2222") + .setRemoteAdbHost("192.168.0.101") + .setSystemPort("8201") + .setUninstallOtherPackages(uninstallPackages) + .setUnlockKey("1111") + .setUnlockType("password") + .setWebviewDevtoolsPort("9543"); + + assertEquals("1234", androidMobileOptions.getAdbPort()); + assertEquals("com.my.Pkg/com.my.Pkg.instrumentation.MyInstrumentation", androidMobileOptions.getAndroidCoverage()); + assertEquals("com.example.pkg.END_EMMA", androidMobileOptions.getAndroidCoverageEndIntent()); + assertEquals("chrome_devtools_remote", androidMobileOptions.getAndroidDeviceSocket()); + assertEquals("/sdcard/Downloads/", androidMobileOptions.getAndroidInstallPath()); + assertEquals("/sdcard/screenshots/", androidMobileOptions.getAndroidScreenshotPath()); + assertEquals(".MainActivity", androidMobileOptions.getAppActivity()); + assertEquals("com.example.android.myApp", androidMobileOptions.getAppPackage()); + assertEquals("SplashActivity,OtherActivity", androidMobileOptions.getAppWaitActivity()); + assertEquals("com.example.android.myApp", androidMobileOptions.getAppWaitPackage()); + assertEquals("api19", androidMobileOptions.getAvd()); + assertEquals("-netfast", androidMobileOptions.getAvdArgs()); + assertEquals("28.0.3", androidMobileOptions.getBuildToolsVersion()); + assertEquals(chromedriverArgs, androidMobileOptions.getChromedriverArgs()); + assertEquals("/abs/path/to/mapping.json", androidMobileOptions.getChromedriverChromeMappingFile()); + assertEquals("/abs/path/to/webdriver", androidMobileOptions.getChromedriverExecutable()); + assertEquals("/abs/path/to/chromedriver/directory", androidMobileOptions.getChromedriverExecutableDir()); + assertEquals("android.intent.action.MAIN", androidMobileOptions.getIntentAction()); + assertEquals("android.intent.category.LAUNCHER", androidMobileOptions.getIntentCategory()); + assertEquals("0x10200000", androidMobileOptions.getIntentFlags()); + assertEquals("androiddebugkey", androidMobileOptions.getKeyAlias()); + assertEquals("foo", androidMobileOptions.getKeyPassword()); + assertEquals("foo", androidMobileOptions.getKeystorePassword()); + assertEquals("/path/to.keystore", androidMobileOptions.getKeystorePath()); + assertEquals("Cyrl", androidMobileOptions.getLocaleScript()); + assertEquals("hscsd", androidMobileOptions.getNetworkSpeed()); + assertEquals("--esn 2222", androidMobileOptions.getOptionalIntentArguments()); + assertEquals("192.168.0.101", androidMobileOptions.getRemoteAdbHost()); + assertEquals("8201", androidMobileOptions.getSystemPort()); + assertEquals(uninstallPackages, androidMobileOptions.getUninstallOtherPackages()); + assertEquals("1111", androidMobileOptions.getUnlockKey()); + assertEquals("password", androidMobileOptions.getUnlockType()); + assertEquals("9543", androidMobileOptions.getWebviewDevtoolsPort()); } } From 3f08c47eca33aa8b19ce80f4d7476bca6e586f75 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 30 Mar 2020 16:03:01 -0500 Subject: [PATCH 06/22] support enums for applicable setters --- .../appium/java_client/android/AndroidMobileOptions.java | 8 ++++++++ .../java/io/appium/java_client/android/UnlockType.java | 5 +++++ .../appium/java_client/android/AndroidOptionsTest.java | 9 +++++++++ 3 files changed, 22 insertions(+) create mode 100644 src/main/java/io/appium/java_client/android/UnlockType.java diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index 24d3232f6..2b512d8f9 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -503,6 +503,10 @@ public AndroidMobileOptions setNetworkSpeed(String speed) { return amend(AndroidMobileCapabilityType.NETWORK_SPEED, speed); } + public AndroidMobileOptions setNetworkSpeed(NetworkSpeed speed) { + return amend(AndroidMobileCapabilityType.NETWORK_SPEED, speed.name().toLowerCase()); + } + public String getNetworkSpeed() { return (String) getCapability(AndroidMobileCapabilityType.NETWORK_SPEED); } @@ -643,6 +647,10 @@ public AndroidMobileOptions setUnlockType(String type) { return amend(AndroidMobileCapabilityType.UNLOCK_TYPE, type); } + public AndroidMobileOptions setUnlockType(UnlockType type) { + return amend(AndroidMobileCapabilityType.UNLOCK_TYPE, type.name().toLowerCase()); + } + public String getUnlockType() { return (String) getCapability(AndroidMobileCapabilityType.UNLOCK_TYPE); } diff --git a/src/main/java/io/appium/java_client/android/UnlockType.java b/src/main/java/io/appium/java_client/android/UnlockType.java new file mode 100644 index 000000000..6b4fbce93 --- /dev/null +++ b/src/main/java/io/appium/java_client/android/UnlockType.java @@ -0,0 +1,5 @@ +package io.appium.java_client.android; + +public enum UnlockType { + PIN, PASSWORD, PATTERN, FINGERPRINT +} diff --git a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java index afff25969..38c2cba01 100644 --- a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java +++ b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java @@ -299,4 +299,13 @@ public void setsAndroidStringCapabilities() { assertEquals("password", androidMobileOptions.getUnlockType()); assertEquals("9543", androidMobileOptions.getWebviewDevtoolsPort()); } + + @Test + public void setsAndroidEnumCapabilities() { + androidMobileOptions.setNetworkSpeed(NetworkSpeed.EVDO) + .setUnlockType(UnlockType.PASSWORD); + + assertEquals("evdo", androidMobileOptions.getNetworkSpeed()); + assertEquals("password", androidMobileOptions.getUnlockType()); + } } From 7a626af553b7ae1cb929b2b0b1aa2caab9e1c3c0 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 30 Mar 2020 20:22:40 -0500 Subject: [PATCH 07/22] add javadocs to android mobile options --- .../android/AndroidMobileOptions.java | 1051 ++++++++++++++++- 1 file changed, 1045 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index 2b512d8f9..875150593 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -26,651 +26,1690 @@ import java.util.List; public class AndroidMobileOptions extends MobileOptions { + + /** + * Creates new instance with platformName specified for Android. + */ public AndroidMobileOptions() { setPlatformName(MobilePlatform.ANDROID); } + /** + * Creates new instance with provided capabilities capabilities. + * + * @param source is Capabilities instance to merge into new instance + */ public AndroidMobileOptions(Capabilities source) { this(); merge(source); } + /** + * Set the Timeout in milliseconds used to wait for adb command execution. + * + * @param ms is the number of milliseconds to wait for adb command execution. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ADB_EXEC_TIMEOUT + */ public AndroidMobileOptions setAdbExecTimeout(Duration ms) { return amend(AndroidMobileCapabilityType.ADB_EXEC_TIMEOUT, ms); } + /** + * Get the Timeout in milliseconds used to wait for adb command execution. + * + * @return Duration to wait for adb command execution. + * @see AndroidMobileCapabilityType#ADB_EXEC_TIMEOUT + */ public Duration getAdbExecTimeout() { return (Duration) getCapability(AndroidMobileCapabilityType.ADB_EXEC_TIMEOUT); } + /** + * Set the port used to connect to the ADB server. + * + * @param port is the port to connect to the ADB server. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ADB_PORT + */ public AndroidMobileOptions setAdbPort(String port) { return amend(AndroidMobileCapabilityType.ADB_PORT, port); } + /** + * Get the port used to connect to the ADB server. + * + * @return String of the port used to connect to the ADB server. + * @see AndroidMobileCapabilityType#ADB_PORT + */ public String getAdbPort() { return (String) getCapability(AndroidMobileCapabilityType.ADB_PORT); } + /** + * Set the app to allow installation of a test package which has android:testOnly="true" in the manifest. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ALLOW_TEST_PACKAGES + */ public AndroidMobileOptions setAllowTestPackages() { return setAllowTestPackages(true); } + /** + * Set whether to allow installation of a test package which has android:testOnly="true" in the manifest. + * + * @param bool when true will be able install a test package marked testOnly. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ALLOW_TEST_PACKAGES + */ public AndroidMobileOptions setAllowTestPackages(boolean bool) { return amend(AndroidMobileCapabilityType.ALLOW_TEST_PACKAGES, bool); } + /** + * Get whether installation of a test package which has android:testOnly="true" in the manifest is allowed. + * + * @return true if able to install a test package marked testOnly. + * @see AndroidMobileCapabilityType#ALLOW_TEST_PACKAGES + */ public boolean doesAllowTestPackages() { return (boolean) getCapability(AndroidMobileCapabilityType.ALLOW_TEST_PACKAGES); } + /** + * Set the fully qualified instrumentation class. + * + * @param coverage is the fully qualified instrumentation class. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ANDROID_COVERAGE + */ public AndroidMobileOptions setAndroidCoverage(String coverage) { return amend(AndroidMobileCapabilityType.ANDROID_COVERAGE, coverage); } + /** + * Get the fully qualified instrumentation class. + * + * @return String of the fully qualified instrumentation class. + * @see AndroidMobileCapabilityType#ANDROID_COVERAGE + */ public String getAndroidCoverage() { return (String) getCapability(AndroidMobileCapabilityType.ANDROID_COVERAGE); } + /** + * Set the broadcast action which is used to dump coverage into file system. + * + * @param coverage is the action to dump coverage into file system. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ANDROID_COVERAGE_END_INTENT + */ public AndroidMobileOptions setAndroidCoverageEndIntent(String coverage) { return amend(AndroidMobileCapabilityType.ANDROID_COVERAGE_END_INTENT, coverage); } + /** + * Get the broadcast action which is used to dump coverage into file system. + * + * @return String of the broadcast action which is used to dump coverage into file system. + * @see AndroidMobileCapabilityType#ANDROID_COVERAGE_END_INTENT + */ public String getAndroidCoverageEndIntent() { return (String) getCapability(AndroidMobileCapabilityType.ANDROID_COVERAGE_END_INTENT); } + /** + * Set the timeout to wait for a device to become ready after booting. + * + * @param seconds is the number of seconds to wait for a device to become ready after booting. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ANDROID_DEVICE_READY_TIMEOUT + */ public AndroidMobileOptions setAndroidDeviceReadyTimeout(Duration seconds) { return amend(AndroidMobileCapabilityType.ANDROID_DEVICE_READY_TIMEOUT, seconds); } + /** + * Get the timeout to wait for a device to become ready after booting. + * + * @return Duration to wait for a device to become ready after booting. + * @see AndroidMobileCapabilityType#ANDROID_DEVICE_READY_TIMEOUT + */ public Duration getAndroidDeviceReadyTimeout() { return (Duration) getCapability(AndroidMobileCapabilityType.ANDROID_DEVICE_READY_TIMEOUT); } + /** + * Set the devtools socket name. + * + * @param activity is the devtools socket name. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ANDROID_DEVICE_SOCKET + */ public AndroidMobileOptions setAndroidDeviceSocket(String activity) { return amend(AndroidMobileCapabilityType.ANDROID_DEVICE_SOCKET, activity); } + /** + * Get the devtools socket name. + * + * @return String of the devtools socket name. + * @see AndroidMobileCapabilityType#ANDROID_DEVICE_SOCKET + */ public String getAndroidDeviceSocket() { return (String) getCapability(AndroidMobileCapabilityType.ANDROID_DEVICE_SOCKET); } + /** + * Set the name of the directory on the device in which the apk will be pushed before install. + * + * @param path is the directory on the device in which the apk will be pushed before install. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ANDROID_INSTALL_PATH + */ public AndroidMobileOptions setAndroidInstallPath(String path) { return amend(AndroidMobileCapabilityType.ANDROID_INSTALL_PATH, path); } + /** + * Get the name of the directory on the device in which the apk will be pushed before install. + * + * @return String of the name of the directory on the device in which the apk will be pushed before install. + * @see AndroidMobileCapabilityType#ANDROID_INSTALL_PATH + */ public String getAndroidInstallPath() { return (String) getCapability(AndroidMobileCapabilityType.ANDROID_INSTALL_PATH); } + /** + * Set the timeout to wait for an apk to install to the device. + * + * @param ms is the number of milliseconds to wait for an apk to install to the device. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ANDROID_INSTALL_TIMEOUT + */ public AndroidMobileOptions setAndroidInstallTimeout(Duration ms) { return amend(AndroidMobileCapabilityType.ANDROID_INSTALL_TIMEOUT, ms); } + /** + * Get the timeout to wait for an apk to install to the device. + * + * @return Duration to wait for an apk to install to the device. + * @see AndroidMobileCapabilityType#ANDROID_INSTALL_TIMEOUT + */ public Duration getAndroidInstallTimeout() { return (Duration) getCapability(AndroidMobileCapabilityType.ANDROID_INSTALL_TIMEOUT); } + /** + * Set the app to allow for correct handling of orientation on landscape-oriented devices. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ANDROID_NATURAL_ORIENTATION + */ public AndroidMobileOptions setAndroidNaturalOrientation() { return setAndroidNaturalOrientation(true); } + /** + * Set whether to allow for correct handling of orientation on landscape-oriented devices. + * + * @param bool when true allows for correct handling of orientation on landscape-oriented devices. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ANDROID_NATURAL_ORIENTATION + */ public AndroidMobileOptions setAndroidNaturalOrientation(boolean bool) { return amend(AndroidMobileCapabilityType.ANDROID_NATURAL_ORIENTATION, bool); } + /** + * Get whether correct handling of orientation on landscape-oriented devices is allowed. + * + * @return true if correct handling of orientation on landscape-oriented devices is allowed. + * @see AndroidMobileCapabilityType#ANDROID_NATURAL_ORIENTATION + */ public boolean isAndroidNaturalOrientation() { return (boolean) getCapability(AndroidMobileCapabilityType.ANDROID_NATURAL_ORIENTATION); } + /** + * Set the name of the directory on the device in which the screenshot will be put. + * + * @param path is the directory on the device in which the screenshot will be put. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ANDROID_SCREENSHOT_PATH + */ public AndroidMobileOptions setAndroidScreenshotPath(String path) { return amend(AndroidMobileCapabilityType.ANDROID_SCREENSHOT_PATH, path); } + /** + * Get the name of the directory on the device in which the screenshot will be put. + * + * @return String of the name of the directory on the device in which the screenshot will be put. + * @see AndroidMobileCapabilityType#ANDROID_SCREENSHOT_PATH + */ public String getAndroidScreenshotPath() { return (String) getCapability(AndroidMobileCapabilityType.ANDROID_SCREENSHOT_PATH); } + /** + * Set the activity name for the Android activity you want to launch from your package. + * + * @param activity is the name of the activity to launch from the package. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#APP_ACTIVITY + */ public AndroidMobileOptions setAppActivity(String activity) { return amend(AndroidMobileCapabilityType.APP_ACTIVITY, activity); } + /** + * Get the activity name for the Android activity you want to launch from your package. + * + * @return String of the activity name for the Android activity you want to launch from your package. + * @see AndroidMobileCapabilityType#APP_ACTIVITY + */ public String getAppActivity() { return (String) getCapability(AndroidMobileCapabilityType.APP_ACTIVITY); } + /** + * Set the Java package of the Android app you want to run. + * + * @param pkg is the Android app you want to run. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#APP_PACKAGE + */ public AndroidMobileOptions setAppPackage(String pkg) { return amend(AndroidMobileCapabilityType.APP_PACKAGE, pkg); } + /** + * Get the Java package of the Android app you want to run. + * + * @return String of the Java package of the Android app you want to run. + * @see AndroidMobileCapabilityType#APP_PACKAGE + */ public String getAppPackage() { return (String) getCapability(AndroidMobileCapabilityType.APP_PACKAGE); } + /** + * Set the activity name/names, comma separated, for the Android activity you want to wait for. + * + * @param activity is the comma separated activity names for activities to wait for. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#APP_WAIT_ACTIVITY + */ public AndroidMobileOptions setAppWaitActivity(String activity) { return amend(AndroidMobileCapabilityType.APP_WAIT_ACTIVITY, activity); } + /** + * Get the activity name/names, comma separated, for the Android activity to wait for. + * + * @return String of comma separated activity names for the Android activity to wait for. + * @see AndroidMobileCapabilityType#APP_WAIT_ACTIVITY + */ public String getAppWaitActivity() { return (String) getCapability(AndroidMobileCapabilityType.APP_WAIT_ACTIVITY); } + /** + * Set the Timeout used to wait for the appWaitActivity to launch. + * + * @param ms is the number of milliseconds to wait for the appWaitActivity to launch. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#APP_WAIT_DURATION + */ public AndroidMobileOptions setAppWaitDuration(Duration ms) { return amend(AndroidMobileCapabilityType.APP_WAIT_DURATION, ms); } + /** + * Get the timeout used to wait for the appWaitActivity to launch. + * + * @return Duration to wait for the appWaitActivity to launch. + * @see AndroidMobileCapabilityType#APP_WAIT_DURATION + */ public Duration getAppWaitDuration() { return (Duration) getCapability(AndroidMobileCapabilityType.APP_WAIT_DURATION); } + /** + * Set the Java package of the Android app to wait for. + * + * @param pkg is the package of the app to wait for. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#APP_WAIT_PACKAGE + */ public AndroidMobileOptions setAppWaitPackage(String pkg) { return amend(AndroidMobileCapabilityType.APP_WAIT_PACKAGE, pkg); } + /** + * Get the Java package of the Android app to wait for. + * + * @return String of the Java package of the Android app to wait for. + * @see AndroidMobileCapabilityType#APP_WAIT_PACKAGE + */ public String getAppWaitPackage() { return (String) getCapability(AndroidMobileCapabilityType.APP_WAIT_PACKAGE); } + /** + * Set Appium to automatically determine which permissions the app requires and grant them to the app on install. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#AUTO_GRANT_PERMISSIONS + */ public AndroidMobileOptions setAutoGrantPermissions() { return setAutoGrantPermissions(true); } + /** + * Set whether required permissions are determined and granted automatically. + * + * @param bool is true if required app permissions are automatically determined and granted. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#AUTO_GRANT_PERMISSIONS + */ public AndroidMobileOptions setAutoGrantPermissions(boolean bool) { return amend(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, bool); } + /** + * Get whether required permissions are determined and granted automatically. + * + * @return true if required app permissions are automatically determined and granted. + * @see AndroidMobileCapabilityType#AUTO_GRANT_PERMISSIONS + */ public boolean doesAutoGrantPermissions() { return (boolean) getCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS); } + /** + * Set the app to initialize automatically. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#AUTO_LAUNCH + */ public AndroidMobileOptions setAutoLaunch() { return setAutoLaunch(true); } + /** + * Set whether the app will initialize automatically. + * + * @param bool is true if the app automatically initializes. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#AUTO_LAUNCH + */ public AndroidMobileOptions setAutoLaunch(boolean bool) { return amend(AndroidMobileCapabilityType.AUTO_LAUNCH, bool); } + /** + * Get whether the app will initialize automatically. + * + * @return true if the app automatically initializes. + * @see AndroidMobileCapabilityType#AUTO_LAUNCH + */ public boolean doesAutoLaunch() { return (boolean) getCapability(AndroidMobileCapabilityType.AUTO_LAUNCH); } + /** + * Set the amount of time to wait for Webview context to become active. + * + * @param ms is the number of milliseconds to wait for Webview context to become active. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#AUTO_WEBVIEW_TIMEOUT + */ public AndroidMobileOptions setAutoWebviewTimeout(Duration ms) { return amend(AndroidMobileCapabilityType.AUTO_WEBVIEW_TIMEOUT, ms); } + /** + * Get the amount of time to wait for Webview context to become active. + * + * @return Duration to wait for Webview context to become active. + * @see AndroidMobileCapabilityType#AUTO_WEBVIEW_TIMEOUT + */ public Duration getAutoWebviewTimeout() { return (Duration) getCapability(AndroidMobileCapabilityType.AUTO_WEBVIEW_TIMEOUT); } + /** + * Set the name of avd to launch. + * + * @param name is the name of avd to launch. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#AVD + */ public AndroidMobileOptions setAvd(String name) { return amend(AndroidMobileCapabilityType.AVD, name); } + /** + * Get the name of avd to launch. + * + * @return String of the name of avd to launch. + * @see AndroidMobileCapabilityType#AVD + */ public String getAvd() { return (String) getCapability(AndroidMobileCapabilityType.AVD); } + /** + * Set the additional emulator arguments used when launching an avd. + * + * @param args is the additional arguments for launching avd on emulator. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#AVD_ARGS + */ public AndroidMobileOptions setAvdArgs(String args) { return amend(AndroidMobileCapabilityType.AVD_ARGS, args); } + /** + * Get the additional emulator arguments used when launching an avd. + * + * @return String of the additional emulator arguments used when launching an avd. + * @see AndroidMobileCapabilityType#AVD_ARGS + */ public String getAvdArgs() { return (String) getCapability(AndroidMobileCapabilityType.AVD_ARGS); } + /** + * Set the wait time for an avd to launch and connect to ADB. + * + * @param ms is the number of milliseconds to wait for an avd to launch and connect to ADB. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#AVD_LAUNCH_TIMEOUT + */ public AndroidMobileOptions setAvdLaunchTimeout(Duration ms) { return amend(AndroidMobileCapabilityType.AVD_LAUNCH_TIMEOUT, ms); } + /** + * Get the wait time for an avd to launch and connect to ADB. + * + * @return Duration to wait for an avd to launch and connect to ADB. + * @see AndroidMobileCapabilityType#AVD_LAUNCH_TIMEOUT + */ public Duration getAvdLaunchTimeout() { return (Duration) getCapability(AndroidMobileCapabilityType.AVD_LAUNCH_TIMEOUT); } + /** + * Set the wait time for an avd to finish its boot animations. + * + * @param ms is the number of milliseconds to wait for an avd to finish its boot animations. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#AVD_READY_TIMEOUT + */ public AndroidMobileOptions setAvdReadyTimeout(Duration ms) { return amend(AndroidMobileCapabilityType.AVD_READY_TIMEOUT, ms); } + /** + * Get the the wait time for an avd to finish its boot animations. + * + * @return Duration to wait for an avd to finish its boot animations. + * @see AndroidMobileCapabilityType#AVD_READY_TIMEOUT + */ public Duration getAvdReadyTimeout() { return (Duration) getCapability(AndroidMobileCapabilityType.AVD_READY_TIMEOUT); } - public AndroidMobileOptions setBuildToolsVersion(String pkg) { - return amend(AndroidMobileCapabilityType.BUILD_TOOLS_VERSION, pkg); + /** + * Set the Android build-tools version to be something different than the default. + * + * @param version is the version of Android build-tools to use. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#BUILD_TOOLS_VERSION + */ + public AndroidMobileOptions setBuildToolsVersion(String version) { + return amend(AndroidMobileCapabilityType.BUILD_TOOLS_VERSION, version); } + /** + * Get the Android build-tools version to be something different than the default. + * + * @return String of the Android build-tools version to be something different than the default. + * @see AndroidMobileCapabilityType#BUILD_TOOLS_VERSION + */ public String getBuildToolsVersion() { return (String) getCapability(AndroidMobileCapabilityType.BUILD_TOOLS_VERSION); } + /** + * Set the arguments to be passed to the chromedriver binary when it's run by Appium.. + * + * @param args is the List of arguments to be passed to the chromedriver. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_ARGS + */ public AndroidMobileOptions setChromedriverArgs(List args) { return amend(AndroidMobileCapabilityType.CHROMEDRIVER_ARGS, args); } + /** + * Get the arguments to be passed to the chromedriver binary when it's run by Appium.. + * + * @return list of String arguments to be passed to the chromedriver binary when it's run by Appium. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_ARGS + */ public Object getChromedriverArgs() { return getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_ARGS); } + /** + * Set the file location which maps Chromedriver versions to the minimum Chrome version that it supports. + * + * @param path is the absolute path to a file mapping Chromedriver versions to Chrome versions. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_CHROME_MAPPING_FILE + */ public AndroidMobileOptions setChromedriverChromeMappingFile(String path) { return amend(AndroidMobileCapabilityType.CHROMEDRIVER_CHROME_MAPPING_FILE, path); } + /** + * Get the file location which maps Chromedriver versions to the minimum Chrome version that it supports. + * + * @return String of the file location which maps Chromedriver versions to the minimum supported Chrome version. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_CHROME_MAPPING_FILE + */ public String getChromedriverChromeMappingFile() { return (String) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_CHROME_MAPPING_FILE); } + /** + * Set the chromedriver flag --disable-build-check for Chrome webview tests. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_DISABLE_BUILD_CHECK + */ public AndroidMobileOptions setChromedriverDisableBuildCheck() { return setChromedriverDisableBuildCheck(true); } + /** + * Set whether chromedriver flag --disable-build-check is added for Chrome webview tests. + * + * @param bool when true adds --disable-build-check for Chrome webview. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_DISABLE_BUILD_CHECK + */ public AndroidMobileOptions setChromedriverDisableBuildCheck(boolean bool) { return amend(AndroidMobileCapabilityType.CHROMEDRIVER_DISABLE_BUILD_CHECK, bool); } + /** + * Get whether chromedriver flag --disable-build-check is added for Chrome webview tests. + * + * @return true if --disable-build-check for Chrome webview is added. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_DISABLE_BUILD_CHECK + */ public boolean doesChromedriverDisableBuildCheck() { return (boolean) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_DISABLE_BUILD_CHECK); } + /** + * Set the path to webdriver executable. + * + * @param path is the absolute local path to webdriver executable. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_EXECUTABLE + */ public AndroidMobileOptions setChromedriverExecutable(String path) { return amend(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE, path); } + /** + * Get the path to webdriver executable. + * + * @return String of the path to webdriver executable. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_EXECUTABLE + */ public String getChromedriverExecutable() { return (String) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE); } + /** + * Set the directory to look for Chromedriver executables in, for automatic discovery of compatible Chromedrivers. + * + * @param dir is the absolute path of the directory to automatically discover compatible Chromedriver executable. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_EXECUTABLE_DIR + */ public AndroidMobileOptions setChromedriverExecutableDir(String dir) { return amend(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE_DIR, dir); } + /** + * Get the directory to look for Chromedriver executables in, for automatic discovery of compatible Chromedrivers. + * + * @return String of the directory of Chromedriver executables. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_EXECUTABLE_DIR + */ public String getChromedriverExecutableDir() { return (String) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE_DIR); } + /** + * Set the port to start Chromedriver on. + * + * @param port is the number of the port to use for Chromedriver. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_PORT + */ public AndroidMobileOptions setChromedriverPort(int port) { return amend(AndroidMobileCapabilityType.CHROMEDRIVER_PORT, port); } + /** + * Get the port Chromedriver starts on. + * + * @return Integer of the port Chromedriver starts on. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_PORT + */ public int getChromedriverPort() { return (int) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_PORT); } + /** + * Set the valid ports for Appium to use for communication with Chromedrivers. + * + * @param ports is the list of ports for Appium to use with Chromedrivers. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#BUILD_TOOLS_VERSION + */ public AndroidMobileOptions setChromedriverPorts(List ports) { return amend(AndroidMobileCapabilityType.BUILD_TOOLS_VERSION, ports); } + /** + * Get the valid ports for Appium to use for communication with Chromedrivers. + * + * @return list of Integers for the valid ports for Appium to use for communication with Chromedrivers. + * @see AndroidMobileCapabilityType#BUILD_TOOLS_VERSION + */ public Object getChromedriverPorts() { return getCapability(AndroidMobileCapabilityType.BUILD_TOOLS_VERSION); } + /** + * Set the app to bypass automatic Chromedriver configuration and use the version that comes downloaded with Appium. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_DISABLE_BUILD_CHECK + */ public AndroidMobileOptions setChromedriverUseSystemExecutable() { return setChromedriverUseSystemExecutable(true); } + /** + * Set whether to bypass automatic Chromedriver configuration and use the version that comes downloaded with Appium. + * + * @param bool when true uses the version of Chromedriver that comes with Appium. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_DISABLE_BUILD_CHECK + */ public AndroidMobileOptions setChromedriverUseSystemExecutable(boolean bool) { return amend(AndroidMobileCapabilityType.CHROMEDRIVER_DISABLE_BUILD_CHECK, bool); } + /** + * Get whether to bypass automatic Chromedriver configuration and use the version that comes downloaded with Appium. + * + * @return true if using the version of Chromedriver that comes with Appium. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_DISABLE_BUILD_CHECK + */ public boolean doesChromedriverUseSystemExecutable() { return (boolean) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_DISABLE_BUILD_CHECK); } + /** + * Set the chromeOptions capability for ChromeDriver. + * + * @param opts is the chromeoptions for ChromeDriver. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_EXECUTABLE_DIR + */ public AndroidMobileOptions setChromeOptions(ChromeOptions opts) { return amend(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE_DIR, opts); } + /** + * Get the chromeOptions capability for ChromeDriver. + * + * @return ChromeOptions set for use with ChromeDriver. + * @see AndroidMobileCapabilityType#CHROMEDRIVER_EXECUTABLE_DIR + */ public Object getChromeOptions() { return getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE_DIR); } + /** + * Set the timeout for device to become ready. + * + * @param seconds is the number of seconds to wait for the device to become ready. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#DEVICE_READY_TIMEOUT + */ public AndroidMobileOptions setDeviceReadyTimeout(Duration seconds) { return amend(AndroidMobileCapabilityType.DEVICE_READY_TIMEOUT, seconds); } + /** + * Get the timeout for device to become ready. + * + * @return Duration to wait for device to become ready. + * @see AndroidMobileCapabilityType#DEVICE_READY_TIMEOUT + */ public Duration getDeviceReadyTimeout() { return (Duration) getCapability(AndroidMobileCapabilityType.DEVICE_READY_TIMEOUT); } + /** + * Set the application to disable Android watchers for when application is not responding or crashes. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#DISABLE_ANDROID_WATCHERS + */ public AndroidMobileOptions setDisableAndroidWatchers() { return setDisableAndroidWatchers(true); } + /** + * Set whether the application disables Android watchers for when application is not responding or crashes. + * + * @param bool when true disables Android watchers for when application is not responding or crashes. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#DISABLE_ANDROID_WATCHERS + */ public AndroidMobileOptions setDisableAndroidWatchers(boolean bool) { return amend(AndroidMobileCapabilityType.DISABLE_ANDROID_WATCHERS, bool); } + /** + * Get whether the application disables Android watchers for when application is not responding or crashes. + * + * @return true if Android watchers for when application is not responding or crashes are disabled. + * @see AndroidMobileCapabilityType#DISABLE_ANDROID_WATCHERS + */ public boolean doesDisableAndroidWatchers() { return (boolean) getCapability(AndroidMobileCapabilityType.DISABLE_ANDROID_WATCHERS); } + /** + * Set the device animation scale to zero. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#DISABLE_WINDOW_ANIMATION + */ public AndroidMobileOptions setDisableWindowAnimation() { return setDisableWindowAnimation(true); } + /** + * Set whether the application has device animation scale of zero. + * + * @param bool when true has device animation scale of zero. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#DISABLE_WINDOW_ANIMATION + */ public AndroidMobileOptions setDisableWindowAnimation(boolean bool) { return amend(AndroidMobileCapabilityType.DISABLE_WINDOW_ANIMATION, bool); } + /** + * Get whether the application has device animation scale of zero. + * + * @return true if device animation scale is zero. + * @see AndroidMobileCapabilityType#DISABLE_WINDOW_ANIMATION + */ public boolean doesDisableWindowAnimation() { return (boolean) getCapability(AndroidMobileCapabilityType.DISABLE_WINDOW_ANIMATION); } + /** + * Set the app not to stop the process of the app under test, before starting the app using adb. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#DONT_STOP_APP_ON_RESET + */ public AndroidMobileOptions setDontStopAppOnReset() { return setDontStopAppOnReset(true); } + /** + * Set whether the app process is not stopped before starting using adb. + * + * @param bool when true does not stop the process of the app under test before starting the app using adb. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#DONT_STOP_APP_ON_RESET + */ public AndroidMobileOptions setDontStopAppOnReset(boolean bool) { return amend(AndroidMobileCapabilityType.DONT_STOP_APP_ON_RESET, bool); } + /** + * Get whether the app process is not stopped before starting using adb. + * + * @return true if the process of the app under test does not stop before starting the app using adb. + * @see AndroidMobileCapabilityType#DONT_STOP_APP_ON_RESET + */ public boolean isDontStopAppOnReset() { return (boolean) getCapability(AndroidMobileCapabilityType.DONT_STOP_APP_ON_RESET); } + /** + * Set to always install the current application build independently of the currently installed version of it. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ENFORCE_APP_INSTALL + */ public AndroidMobileOptions setEnforceAppInstall() { return setEnforceAppInstall(true); } + /** + * Set whether to always install the current application build independently of the currently installed version. + * + * @param bool when true will install the current application build independently of the installed version. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ENFORCE_APP_INSTALL + */ public AndroidMobileOptions setEnforceAppInstall(boolean bool) { return amend(AndroidMobileCapabilityType.ENFORCE_APP_INSTALL, bool); } + /** + * Get whether the current application build is always isntalled independently of the currently installed version. + * + * @return true if the current application build is installed independently of the currently installed version. + * @see AndroidMobileCapabilityType#ENFORCE_APP_INSTALL + */ public boolean doesEnforceAppInstall() { return (boolean) getCapability(AndroidMobileCapabilityType.ENFORCE_APP_INSTALL); } + /** + * Set the app to augment its webview detection with page detection. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ENSURE_WEBVIEWS_HAVE_PAGES + */ public AndroidMobileOptions setEnsureWebviewsHavePages() { return setEnsureWebviewsHavePages(true); } + /** + * Set whether to augment webview detection with page detection. + * + * @param bool when true augments webview detection with page detection. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#ENSURE_WEBVIEWS_HAVE_PAGES + */ public AndroidMobileOptions setEnsureWebviewsHavePages(boolean bool) { return amend(AndroidMobileCapabilityType.ENSURE_WEBVIEWS_HAVE_PAGES, bool); } + /** + * Get whether to augment webview detection with page detection. + * + * @return true if webview detection is augmented with page detection. + * @see AndroidMobileCapabilityType#ENSURE_WEBVIEWS_HAVE_PAGES + */ public boolean doesEnsureWebviewsHavePages() { return (boolean) getCapability(AndroidMobileCapabilityType.ENSURE_WEBVIEWS_HAVE_PAGES); } + /** + * Set the app to use GPS location for emulators. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#GPS_ENABLED + */ public AndroidMobileOptions setGpsEnabled() { return setGpsEnabled(true); } + /** + * Set whether to use GPS location for emulators. + * + * @param bool when true will enable GPS location for emulators. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#GPS_ENABLED + */ public AndroidMobileOptions setGpsEnabled(boolean bool) { return amend(AndroidMobileCapabilityType.GPS_ENABLED, bool); } + /** + * Get whether to use GPS location for emulators. + * + * @return true if GPS location for emulators is enabled. + * @see AndroidMobileCapabilityType#GPS_ENABLED + */ public boolean isGpsEnabled() { return (boolean) getCapability(AndroidMobileCapabilityType.GPS_ENABLED); } + /** + * Set the accessibility commands to run faster by ignoring some elements. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#IGNORE_UNIMPORTANT_VIEWS + */ public AndroidMobileOptions setIgnoreUnimportantViews() { return setIgnoreUnimportantViews(true); } + /** + * Set whether accessibility commands run faster by ignoring some elements. + * + * @param bool when true will ignore some elements to improve performance. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#IGNORE_UNIMPORTANT_VIEWS + */ public AndroidMobileOptions setIgnoreUnimportantViews(boolean bool) { return amend(AndroidMobileCapabilityType.IGNORE_UNIMPORTANT_VIEWS, bool); } + /** + * Get whether accessibility commands run faster by ignoring some elements. + * + * @return true if some elements are ignored to improve performance. + * @see AndroidMobileCapabilityType#IGNORE_UNIMPORTANT_VIEWS + */ public boolean doesIgnoreUnimportantViews() { return (boolean) getCapability(AndroidMobileCapabilityType.IGNORE_UNIMPORTANT_VIEWS); } + /** + * Set the intent action which will be used to start activity. + * + * @param action is the action used to start the activity. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#INTENT_ACTION + */ public AndroidMobileOptions setIntentAction(String action) { return amend(AndroidMobileCapabilityType.INTENT_ACTION, action); } + /** + * Get the intent action which will be used to start activity. + * + * @return String of the intent action which will be used to start activity. + * @see AndroidMobileCapabilityType#INTENT_ACTION + */ public String getIntentAction() { return (String) getCapability(AndroidMobileCapabilityType.INTENT_ACTION); } + /** + * Set the intent category which will be used to start activity. + * + * @param category is the category used to start activity. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#INTENT_CATEGORY + */ public AndroidMobileOptions setIntentCategory(String category) { return amend(AndroidMobileCapabilityType.INTENT_CATEGORY, category); } + /** + * Get the intent category which will be used to start activity. + * + * @return String of the intent category which will be used to start activity. + * @see AndroidMobileCapabilityType#INTENT_CATEGORY + */ public String getIntentCategory() { return (String) getCapability(AndroidMobileCapabilityType.INTENT_CATEGORY); } - public AndroidMobileOptions setIntentFlags(String category) { - return amend(AndroidMobileCapabilityType.INTENT_FLAGS, category); + /** + * Set the flags that will be used to start activity. + * + * @param flags is the flags used to start activity. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#INTENT_FLAGS + */ + public AndroidMobileOptions setIntentFlags(String flags) { + return amend(AndroidMobileCapabilityType.INTENT_FLAGS, flags); } + /** + * Get the flags that will be used to start activity. + * + * @return String of the flags that will be used to start activity. + * @see AndroidMobileCapabilityType#INTENT_FLAGS + */ public String getIntentFlags() { return (String) getCapability(AndroidMobileCapabilityType.INTENT_FLAGS); } + /** + * Set the emulator to not display the screen. + * + * @param bool when true will not display the emulator screen. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#IS_HEADLESS + */ public AndroidMobileOptions setIsHeadless(boolean bool) { return amend(AndroidMobileCapabilityType.IS_HEADLESS, bool); } + /** + * Get the emulator to not display the screen. + * + * @return true if emulator is not to display the screen. + * @see AndroidMobileCapabilityType#IS_HEADLESS + */ public boolean isHeadless() { return (boolean) getCapability(AndroidMobileCapabilityType.IS_HEADLESS); } + /** + * Set the alias for the key. + * + * @param alias is the key alias. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#KEY_ALIAS + */ public AndroidMobileOptions setKeyAlias(String alias) { return amend(AndroidMobileCapabilityType.KEY_ALIAS, alias); } + /** + * Get the alias for the key. + * + * @return String of the key alias. + * @see AndroidMobileCapabilityType#KEY_ALIAS + */ public String getKeyAlias() { return (String) getCapability(AndroidMobileCapabilityType.KEY_ALIAS); } + /** + * Set the password for the key. + * + * @param password is the key password. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#KEY_PASSWORD + */ public AndroidMobileOptions setKeyPassword(String password) { return amend(AndroidMobileCapabilityType.KEY_PASSWORD, password); } + /** + * Get the password for the key. + * + * @return String of the key password. + * @see AndroidMobileCapabilityType#KEY_PASSWORD + */ public String getKeyPassword() { return (String) getCapability(AndroidMobileCapabilityType.KEY_PASSWORD); } + /** + * Set the password for custom keystore. + * + * @param password is the password for the custom keystore. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#KEYSTORE_PASSWORD + */ public AndroidMobileOptions setKeystorePassword(String password) { return amend(AndroidMobileCapabilityType.KEYSTORE_PASSWORD, password); } + /** + * Get the password for custom keystore. + * + * @return String of the custom keystore password. + * @see AndroidMobileCapabilityType#KEYSTORE_PASSWORD + */ public String getKeystorePassword() { return (String) getCapability(AndroidMobileCapabilityType.KEYSTORE_PASSWORD); } + /** + * Set the path to custom keystore. + * + * @param path is the path to the custom keystore. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#KEYSTORE_PATH + */ public AndroidMobileOptions setKeystorePath(String path) { return amend(AndroidMobileCapabilityType.KEYSTORE_PATH, path); } + /** + * Get the path to custom keystore. + * + * @return String of the custom keystore path. + * @see AndroidMobileCapabilityType#KEYSTORE_PATH + */ public String getKeystorePath() { return (String) getCapability(AndroidMobileCapabilityType.KEYSTORE_PATH); } - public AndroidMobileOptions setLocaleScript(String path) { - return amend(AndroidMobileCapabilityType.LOCALE_SCRIPT, path); + /** + * Set the locale script. + * + * @param script is the locale script. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#LOCALE_SCRIPT + */ + public AndroidMobileOptions setLocaleScript(String script) { + return amend(AndroidMobileCapabilityType.LOCALE_SCRIPT, script); } + /** + * Get the locale script. + * + * @return String of the locale script. + * @see AndroidMobileCapabilityType#LOCALE_SCRIPT + */ public String getLocaleScript() { return (String) getCapability(AndroidMobileCapabilityType.LOCALE_SCRIPT); } + /** + * Set the web context to use native (adb) method for taking a screenshot. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#NATIVE_WEB_SCREENSHOT + */ public AndroidMobileOptions setNativeWebScreenshot() { return setNativeWebScreenshot(true); } + /** + * Set whether the web context uses native (adb) method for taking a screenshot or proxies to ChromeDriver. + * + * @param bool when true uses the native method for taking a screenshot. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#NATIVE_WEB_SCREENSHOT + */ public AndroidMobileOptions setNativeWebScreenshot(boolean bool) { return amend(AndroidMobileCapabilityType.NATIVE_WEB_SCREENSHOT, bool); } + /** + * Get whether the web context uses native (adb) method for taking a screenshot or proxies to ChromeDriver. + * + * @return true if using the native method for taking a screenshot. + * @see AndroidMobileCapabilityType#NATIVE_WEB_SCREENSHOT + */ public boolean doesNativeWebScreenshot() { return (boolean) getCapability(AndroidMobileCapabilityType.NATIVE_WEB_SCREENSHOT); } + /** + * Set the network speed emulation. + * + * @param speed is the network speed emulation. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#NETWORK_SPEED + */ public AndroidMobileOptions setNetworkSpeed(String speed) { return amend(AndroidMobileCapabilityType.NETWORK_SPEED, speed); } + /** + * Set the network speed emulation. + * + * @param speed is the network speed emulation. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#NETWORK_SPEED + */ public AndroidMobileOptions setNetworkSpeed(NetworkSpeed speed) { return amend(AndroidMobileCapabilityType.NETWORK_SPEED, speed.name().toLowerCase()); } + /** + * Get the network speed emulation. + * + * @return String of the network speed emulation. + * @see AndroidMobileCapabilityType#NETWORK_SPEED + */ public String getNetworkSpeed() { return (String) getCapability(AndroidMobileCapabilityType.NETWORK_SPEED); } + /** + * Set the app to skip checking and signing with debug keys. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#NO_SIGN + */ public AndroidMobileOptions setNoSign() { return setNoSign(true); } + /** + * Set whether to skip checking and signing the app with debug keys. + * + * @param bool when true skips checking and signing the app with debug keys. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#NO_SIGN + */ public AndroidMobileOptions setNoSign(boolean bool) { return amend(AndroidMobileCapabilityType.NO_SIGN, bool); } + /** + * Get whether to skip checking and signing the app with debug keys. + * + * @return true if checking and signing the app with debug keys is skipped + * @see AndroidMobileCapabilityType#NO_SIGN + */ public boolean isNoSign() { return (boolean) getCapability(AndroidMobileCapabilityType.NO_SIGN); } + /** + * Set the additional intent arguments that will be used to start activity. + * + * @param speed is the additional intent arguments that will be used to start activity. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#OPTIONAL_INTENT_ARGUMENTS + */ public AndroidMobileOptions setOptionalIntentArguments(String speed) { return amend(AndroidMobileCapabilityType.OPTIONAL_INTENT_ARGUMENTS, speed); } + /** + * Get the additional intent arguments that will be used to start activity. + * + * @return String of the additional intent arguments that will be used to start activity. + * @see AndroidMobileCapabilityType#OPTIONAL_INTENT_ARGUMENTS + */ public String getOptionalIntentArguments() { return (String) getCapability(AndroidMobileCapabilityType.OPTIONAL_INTENT_ARGUMENTS); } + /** + * Set the app to kill ChromeDriver session when moving to a non-ChromeDriver webview. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#RECREATE_CHROME_DRIVER_SESSIONS + */ public AndroidMobileOptions setRecreateChromeDriverSessions() { return setRecreateChromeDriverSessions(true); } + /** + * Set whether to kill ChromeDriver session when moving to a non-ChromeDriver webview. + * + * @param bool when true kills ChromeDriver session when moving to a non-ChromeDriver webview. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#RECREATE_CHROME_DRIVER_SESSIONS + */ public AndroidMobileOptions setRecreateChromeDriverSessions(boolean bool) { return amend(AndroidMobileCapabilityType.RECREATE_CHROME_DRIVER_SESSIONS, bool); } + /** + * Get whether to kill ChromeDriver session when moving to a non-ChromeDriver webview. + * + * @return true if kills ChromeDriver session when moving to a non-ChromeDriver webview. + * @see AndroidMobileCapabilityType#RECREATE_CHROME_DRIVER_SESSIONS + */ public boolean doesRecreateChromeDriverSessions() { return (boolean) getCapability(AndroidMobileCapabilityType.RECREATE_CHROME_DRIVER_SESSIONS); } + /** + * Set the optional remote ADB server host. + * + * @param host is the remote ADB server host. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#REMOTE_ADB_HOST + */ public AndroidMobileOptions setRemoteAdbHost(String host) { return amend(AndroidMobileCapabilityType.REMOTE_ADB_HOST, host); } + /** + * Get the optional remote ADB server host. + * + * @return String of . + * @see AndroidMobileCapabilityType#REMOTE_ADB_HOST + */ public String getRemoteAdbHost() { return (String) getCapability(AndroidMobileCapabilityType.REMOTE_ADB_HOST); } + /** + * Set the maximum number of remote cached apks which are pushed to the device-under-test's local storage. + * + * @param num is the maximum number of remote cached apks pushed to local storage. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#REMOTE_APPS_CACHE_LIMIT + */ public AndroidMobileOptions setRemoteAppsCacheLimit(int num) { return amend(AndroidMobileCapabilityType.REMOTE_APPS_CACHE_LIMIT, num); } + /** + * Get the maximum number of remote cached apks which are pushed to the device-under-test's local storage. + * + * @return Integer of the max number of remote cached apks pushed to local storage. + * @see AndroidMobileCapabilityType#REMOTE_APPS_CACHE_LIMIT + */ public int getRemoteAppsCacheLimit() { return (int) getCapability(AndroidMobileCapabilityType.REMOTE_APPS_CACHE_LIMIT); } + /** + * Set the keyboard to reset to its original state after running Unicode tests with unicodeKeyboard capability. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#RESET_KEYBOARD + */ public AndroidMobileOptions setResetKeyboard() { return setResetKeyboard(true); } + /** + * Set whether the keyboard resets to original state after running Unicode tests with unicodeKeyboard capability. + * + * @param bool when true resets the keyboard to its original state after running with unicodeKeyboard. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#RESET_KEYBOARD + */ public AndroidMobileOptions setResetKeyboard(boolean bool) { return amend(AndroidMobileCapabilityType.RESET_KEYBOARD, bool); } + /** + * Get whether the keyboard resets to original state after running Unicode tests with unicodeKeyboard capability. + * + * @return true if the keyboard is reset to its original state after running with unicodeKeyboard. + * @see AndroidMobileCapabilityType#RESET_KEYBOARD + */ public boolean doesResetKeyboard() { return (boolean) getCapability(AndroidMobileCapabilityType.RESET_KEYBOARD); } + /** + * Set the device to skip initialization including installation and running of Settings app and permissions. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#SKIP_DEVICE_INITIALIZATION + */ public AndroidMobileOptions setSkipDeviceInitialization() { return setSkipDeviceInitialization(true); } + /** + * Set whether to skip device initialization including installation and running of Settings app and permissions. + * + * @param bool when true skips device initialization. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#SKIP_DEVICE_INITIALIZATION + */ public AndroidMobileOptions setSkipDeviceInitialization(boolean bool) { return amend(AndroidMobileCapabilityType.SKIP_DEVICE_INITIALIZATION, bool); } + /** + * Get whether to skip device initialization including installation and running of Settings app and permissions. + * + * @return true if device initialization is skipped. + * @see AndroidMobileCapabilityType#SKIP_DEVICE_INITIALIZATION + */ public boolean doesSkipDeviceInitialization() { return (boolean) getCapability(AndroidMobileCapabilityType.SKIP_DEVICE_INITIALIZATION); } + /** + * Set the App to skip capturing logcat. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#SKIP_LOGCAT_CAPTURE + */ public AndroidMobileOptions setSkipLogcatCapture() { return setSkipLogcatCapture(true); } + /** + * Set whether to skip capturing logcat. + * + * @param bool when true does not capture logcat. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#SKIP_LOGCAT_CAPTURE + */ public AndroidMobileOptions setSkipLogcatCapture(boolean bool) { return amend(AndroidMobileCapabilityType.SKIP_LOGCAT_CAPTURE, bool); } + /** + * Get whether to skip capturing logcat. + * + * @return true if not capturing logcat. + * @see AndroidMobileCapabilityType#SKIP_LOGCAT_CAPTURE + */ public boolean doesSkipLogcatCapture() { return (boolean) getCapability(AndroidMobileCapabilityType.SKIP_LOGCAT_CAPTURE); } + /** + * Set the app to skip unlock during session creation. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#SKIP_UNLOCK + */ public AndroidMobileOptions setSkipUnlock() { return setSkipUnlock(true); } + /** + * Set whether to skip unlock during session creation. + * + * @param bool when true skips unlock during session creation. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#SKIP_UNLOCK + */ public AndroidMobileOptions setSkipUnlock(boolean bool) { return amend(AndroidMobileCapabilityType.SKIP_UNLOCK, bool); } + /** + * Get whether to skip unlock during session creation. + * + * @return true if unlock during session creation is skipped. + * @see AndroidMobileCapabilityType#SKIP_UNLOCK + */ public boolean doesSkipUnlock() { return (boolean) getCapability(AndroidMobileCapabilityType.SKIP_UNLOCK); } + /** + * Set the port used to connect to the driver. + * + * @param port is the port used to connect to the driver. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#SYSTEM_PORT + */ public AndroidMobileOptions setSystemPort(String port) { return amend(AndroidMobileCapabilityType.SYSTEM_PORT, port); } + /** + * Get the port used to connect to the driver. + * + * @return String of the port used to connect to the driver. + * @see AndroidMobileCapabilityType#SYSTEM_PORT + */ public String getSystemPort() { return (String) getCapability(AndroidMobileCapabilityType.SYSTEM_PORT); } + /** + * Set the app to enable Unicode input. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#UNICODE_KEYBOARD + */ public AndroidMobileOptions setUnicodeKeyboard() { return setUnicodeKeyboard(true); } + /** + * Set whether to enable Unicode input. + * + * @param bool when true enables Unicode input. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#UNICODE_KEYBOARD + */ public AndroidMobileOptions setUnicodeKeyboard(boolean bool) { return amend(AndroidMobileCapabilityType.UNICODE_KEYBOARD, bool); } + /** + * Get whether to enable Unicode input. + * + * @return true if Unicode input is enabled. + * @see AndroidMobileCapabilityType#UNICODE_KEYBOARD + */ public boolean isUnicodeKeyboard() { return (boolean) getCapability(AndroidMobileCapabilityType.UNICODE_KEYBOARD); } + /** + * Set the list of packages to uninstall before installing apks. + * + * @param packages is the list of packages to uninstall before installing apks. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#UNINSTALL_OTHER_PACKAGES + */ public AndroidMobileOptions setUninstallOtherPackages(List packages) { return amend(AndroidMobileCapabilityType.UNINSTALL_OTHER_PACKAGES, packages); } + /** + * Get the list of packages to uninstall before installing apks. + * + * @return list of Strings for packages to uninstall before installing apks. + * @see AndroidMobileCapabilityType#UNINSTALL_OTHER_PACKAGES + */ public Object getUninstallOtherPackages() { return getCapability(AndroidMobileCapabilityType.UNINSTALL_OTHER_PACKAGES); } + /** + * Set the key pattern to unlock used by unlockType. + * + * @param key is the key pattern to unlock. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#UNLOCK_KEY + */ public AndroidMobileOptions setUnlockKey(String key) { return amend(AndroidMobileCapabilityType.UNLOCK_KEY, key); } + /** + * Get the key pattern to unlock used by unlockType. + * + * @return String of the key pattern to unlock used by unlockType. + * @see AndroidMobileCapabilityType#UNLOCK_KEY + */ public String getUnlockKey() { return (String) getCapability(AndroidMobileCapabilityType.UNLOCK_KEY); } + /** + * Set the device to unlock with particular lock pattern instead of just waking up the device with a helper app. + * + * @param type is the pattern to unlock the device. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#UNLOCK_TYPE + */ public AndroidMobileOptions setUnlockType(String type) { return amend(AndroidMobileCapabilityType.UNLOCK_TYPE, type); } + /** + * Set the device to unlock with particular lock pattern instead of just waking up the device with a helper app. + * + * @param type is the pattern to unlock the device. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#UNLOCK_TYPE + */ public AndroidMobileOptions setUnlockType(UnlockType type) { return amend(AndroidMobileCapabilityType.UNLOCK_TYPE, type.name().toLowerCase()); } + /** + * Get the device to unlock with particular lock pattern instead of just waking up the device with a helper app. + * + * @return String of the device to unlock with particular lock pattern. + * @see AndroidMobileCapabilityType#UNLOCK_TYPE + */ public String getUnlockType() { return (String) getCapability(AndroidMobileCapabilityType.UNLOCK_TYPE); } + /** + * Set to use a custom keystore to sign apks. + * + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#USE_KEYSTORE + */ public AndroidMobileOptions setUseKeystore() { return setUseKeystore(true); } + /** + * Set whether to use a custom keystore to sign apks. + * + * @param bool when true allows using a custom keystore to sign apks. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#USE_KEYSTORE + */ public AndroidMobileOptions setUseKeystore(boolean bool) { return amend(AndroidMobileCapabilityType.USE_KEYSTORE, bool); } + /** + * Get whether to use a custom keystore to sign apks. + * + * @return true if using a custom keystore to sign apks is allowed. + * @see AndroidMobileCapabilityType#USE_KEYSTORE + */ public boolean doesUseKeystore() { return (boolean) getCapability(AndroidMobileCapabilityType.USE_KEYSTORE); } + /** + * Set the TCP port for communication with the webview. + * + * @param port is the port for communicating with the webview. + * @return this MobileOptions, for chaining. + * @see AndroidMobileCapabilityType#WEBVIEW_DEVTOOLS_PORT + */ public AndroidMobileOptions setWebviewDevtoolsPort(String port) { return amend(AndroidMobileCapabilityType.WEBVIEW_DEVTOOLS_PORT, port); } + /** + * Get the TCP port for communication with the webview. + * + * @return String of the TCP port for communication with the webview. + * @see AndroidMobileCapabilityType#WEBVIEW_DEVTOOLS_PORT + */ public String getWebviewDevtoolsPort() { return (String) getCapability(AndroidMobileCapabilityType.WEBVIEW_DEVTOOLS_PORT); } From 664223287e7973d5c78c320bc331d084d4c91239 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Tue, 31 Mar 2020 16:27:18 -0500 Subject: [PATCH 08/22] fix duration parameters to store correct units in capabilities --- .../android/AndroidMobileOptions.java | 72 ++++++++++--------- .../java_client/remote/MobileOptions.java | 9 +-- .../java_client/remote/MobileOptionsTest.java | 2 +- 3 files changed, 46 insertions(+), 37 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index 875150593..598aa2e56 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -47,12 +47,12 @@ public AndroidMobileOptions(Capabilities source) { /** * Set the Timeout in milliseconds used to wait for adb command execution. * - * @param ms is the number of milliseconds to wait for adb command execution. + * @param duration is the number of milliseconds to wait for adb command execution. * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#ADB_EXEC_TIMEOUT */ - public AndroidMobileOptions setAdbExecTimeout(Duration ms) { - return amend(AndroidMobileCapabilityType.ADB_EXEC_TIMEOUT, ms); + public AndroidMobileOptions setAdbExecTimeout(Duration duration) { + return amend(AndroidMobileCapabilityType.ADB_EXEC_TIMEOUT, duration.toMillis()); } /** @@ -62,7 +62,8 @@ public AndroidMobileOptions setAdbExecTimeout(Duration ms) { * @see AndroidMobileCapabilityType#ADB_EXEC_TIMEOUT */ public Duration getAdbExecTimeout() { - return (Duration) getCapability(AndroidMobileCapabilityType.ADB_EXEC_TIMEOUT); + Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.ADB_EXEC_TIMEOUT); + return Duration.ofMillis(duration); } /** @@ -162,12 +163,12 @@ public String getAndroidCoverageEndIntent() { /** * Set the timeout to wait for a device to become ready after booting. * - * @param seconds is the number of seconds to wait for a device to become ready after booting. + * @param duration is the number of seconds to wait for a device to become ready after booting. * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#ANDROID_DEVICE_READY_TIMEOUT */ - public AndroidMobileOptions setAndroidDeviceReadyTimeout(Duration seconds) { - return amend(AndroidMobileCapabilityType.ANDROID_DEVICE_READY_TIMEOUT, seconds); + public AndroidMobileOptions setAndroidDeviceReadyTimeout(Duration duration) { + return amend(AndroidMobileCapabilityType.ANDROID_DEVICE_READY_TIMEOUT, duration.getSeconds()); } /** @@ -177,7 +178,8 @@ public AndroidMobileOptions setAndroidDeviceReadyTimeout(Duration seconds) { * @see AndroidMobileCapabilityType#ANDROID_DEVICE_READY_TIMEOUT */ public Duration getAndroidDeviceReadyTimeout() { - return (Duration) getCapability(AndroidMobileCapabilityType.ANDROID_DEVICE_READY_TIMEOUT); + Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.ANDROID_DEVICE_READY_TIMEOUT); + return Duration.ofSeconds(duration); } /** @@ -225,12 +227,12 @@ public String getAndroidInstallPath() { /** * Set the timeout to wait for an apk to install to the device. * - * @param ms is the number of milliseconds to wait for an apk to install to the device. + * @param duration is the number of milliseconds to wait for an apk to install to the device. * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#ANDROID_INSTALL_TIMEOUT */ - public AndroidMobileOptions setAndroidInstallTimeout(Duration ms) { - return amend(AndroidMobileCapabilityType.ANDROID_INSTALL_TIMEOUT, ms); + public AndroidMobileOptions setAndroidInstallTimeout(Duration duration) { + return amend(AndroidMobileCapabilityType.ANDROID_INSTALL_TIMEOUT, duration.toMillis()); } /** @@ -240,7 +242,8 @@ public AndroidMobileOptions setAndroidInstallTimeout(Duration ms) { * @see AndroidMobileCapabilityType#ANDROID_INSTALL_TIMEOUT */ public Duration getAndroidInstallTimeout() { - return (Duration) getCapability(AndroidMobileCapabilityType.ANDROID_INSTALL_TIMEOUT); + Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.ANDROID_INSTALL_TIMEOUT); + return Duration.ofMillis(duration); } /** @@ -361,12 +364,12 @@ public String getAppWaitActivity() { /** * Set the Timeout used to wait for the appWaitActivity to launch. * - * @param ms is the number of milliseconds to wait for the appWaitActivity to launch. + * @param duration is the number of milliseconds to wait for the appWaitActivity to launch. * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#APP_WAIT_DURATION */ - public AndroidMobileOptions setAppWaitDuration(Duration ms) { - return amend(AndroidMobileCapabilityType.APP_WAIT_DURATION, ms); + public AndroidMobileOptions setAppWaitDuration(Duration duration) { + return amend(AndroidMobileCapabilityType.APP_WAIT_DURATION, duration.toMillis()); } /** @@ -376,7 +379,8 @@ public AndroidMobileOptions setAppWaitDuration(Duration ms) { * @see AndroidMobileCapabilityType#APP_WAIT_DURATION */ public Duration getAppWaitDuration() { - return (Duration) getCapability(AndroidMobileCapabilityType.APP_WAIT_DURATION); + Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.APP_WAIT_DURATION); + return Duration.ofMillis(duration); } /** @@ -465,12 +469,12 @@ public boolean doesAutoLaunch() { /** * Set the amount of time to wait for Webview context to become active. * - * @param ms is the number of milliseconds to wait for Webview context to become active. + * @param duration is the number of milliseconds to wait for Webview context to become active. * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#AUTO_WEBVIEW_TIMEOUT */ - public AndroidMobileOptions setAutoWebviewTimeout(Duration ms) { - return amend(AndroidMobileCapabilityType.AUTO_WEBVIEW_TIMEOUT, ms); + public AndroidMobileOptions setAutoWebviewTimeout(Duration duration) { + return amend(AndroidMobileCapabilityType.AUTO_WEBVIEW_TIMEOUT, duration.toMillis()); } /** @@ -480,7 +484,8 @@ public AndroidMobileOptions setAutoWebviewTimeout(Duration ms) { * @see AndroidMobileCapabilityType#AUTO_WEBVIEW_TIMEOUT */ public Duration getAutoWebviewTimeout() { - return (Duration) getCapability(AndroidMobileCapabilityType.AUTO_WEBVIEW_TIMEOUT); + Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.AUTO_WEBVIEW_TIMEOUT); + return Duration.ofMillis(duration); } /** @@ -528,12 +533,12 @@ public String getAvdArgs() { /** * Set the wait time for an avd to launch and connect to ADB. * - * @param ms is the number of milliseconds to wait for an avd to launch and connect to ADB. + * @param duration is the number of milliseconds to wait for an avd to launch and connect to ADB. * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#AVD_LAUNCH_TIMEOUT */ - public AndroidMobileOptions setAvdLaunchTimeout(Duration ms) { - return amend(AndroidMobileCapabilityType.AVD_LAUNCH_TIMEOUT, ms); + public AndroidMobileOptions setAvdLaunchTimeout(Duration duration) { + return amend(AndroidMobileCapabilityType.AVD_LAUNCH_TIMEOUT, duration.toMillis()); } /** @@ -543,18 +548,19 @@ public AndroidMobileOptions setAvdLaunchTimeout(Duration ms) { * @see AndroidMobileCapabilityType#AVD_LAUNCH_TIMEOUT */ public Duration getAvdLaunchTimeout() { - return (Duration) getCapability(AndroidMobileCapabilityType.AVD_LAUNCH_TIMEOUT); + Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.AVD_LAUNCH_TIMEOUT); + return Duration.ofMillis(duration); } /** * Set the wait time for an avd to finish its boot animations. * - * @param ms is the number of milliseconds to wait for an avd to finish its boot animations. + * @param duration is the number of milliseconds to wait for an avd to finish its boot animations. * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#AVD_READY_TIMEOUT */ - public AndroidMobileOptions setAvdReadyTimeout(Duration ms) { - return amend(AndroidMobileCapabilityType.AVD_READY_TIMEOUT, ms); + public AndroidMobileOptions setAvdReadyTimeout(Duration duration) { + return amend(AndroidMobileCapabilityType.AVD_READY_TIMEOUT, duration.toMillis()); } /** @@ -564,7 +570,8 @@ public AndroidMobileOptions setAvdReadyTimeout(Duration ms) { * @see AndroidMobileCapabilityType#AVD_READY_TIMEOUT */ public Duration getAvdReadyTimeout() { - return (Duration) getCapability(AndroidMobileCapabilityType.AVD_READY_TIMEOUT); + Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.AVD_READY_TIMEOUT); + return Duration.ofMillis(duration); } /** @@ -800,12 +807,12 @@ public Object getChromeOptions() { /** * Set the timeout for device to become ready. * - * @param seconds is the number of seconds to wait for the device to become ready. + * @param duration is the number of seconds to wait for the device to become ready. * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#DEVICE_READY_TIMEOUT */ - public AndroidMobileOptions setDeviceReadyTimeout(Duration seconds) { - return amend(AndroidMobileCapabilityType.DEVICE_READY_TIMEOUT, seconds); + public AndroidMobileOptions setDeviceReadyTimeout(Duration duration) { + return amend(AndroidMobileCapabilityType.DEVICE_READY_TIMEOUT, duration.getSeconds()); } /** @@ -815,7 +822,8 @@ public AndroidMobileOptions setDeviceReadyTimeout(Duration seconds) { * @see AndroidMobileCapabilityType#DEVICE_READY_TIMEOUT */ public Duration getDeviceReadyTimeout() { - return (Duration) getCapability(AndroidMobileCapabilityType.DEVICE_READY_TIMEOUT); + Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.DEVICE_READY_TIMEOUT); + return Duration.ofSeconds(duration); } /** diff --git a/src/main/java/io/appium/java_client/remote/MobileOptions.java b/src/main/java/io/appium/java_client/remote/MobileOptions.java index 56ce8a362..41adafe07 100644 --- a/src/main/java/io/appium/java_client/remote/MobileOptions.java +++ b/src/main/java/io/appium/java_client/remote/MobileOptions.java @@ -338,12 +338,12 @@ public String getLocale() { /** * Set the timeout for new commands. * - * @param seconds is the number of seconds to timeout before seeing a new command. + * @param duration is the number of seconds to timeout before seeing a new command. * @return this MobileOptions, for chaining. * @see MobileCapabilityType#NEW_COMMAND_TIMEOUT */ - public T setNewCommandTimeout(Duration seconds) { - return amend(MobileCapabilityType.NEW_COMMAND_TIMEOUT, seconds); + public T setNewCommandTimeout(Duration duration) { + return amend(MobileCapabilityType.NEW_COMMAND_TIMEOUT, duration.getSeconds()); } /** @@ -353,7 +353,8 @@ public T setNewCommandTimeout(Duration seconds) { * @see MobileCapabilityType#NEW_COMMAND_TIMEOUT */ public Duration getNewCommandTimeout() { - return (Duration) getCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT); + Integer duration = (Integer) getCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT); + return Duration.ofSeconds(duration); } /** diff --git a/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java b/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java index 36fc1cd28..63e35b12a 100644 --- a/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java +++ b/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java @@ -35,7 +35,7 @@ public void acceptsExistingCapabilities() { MutableCapabilities capabilities = new MutableCapabilities(); capabilities.setCapability("deviceName", "Pixel"); capabilities.setCapability("platformVersion", "10"); - capabilities.setCapability("newCommandTimeout", Duration.ofSeconds(60)); + capabilities.setCapability("newCommandTimeout", 60); mobileOptions = new MobileOptions<>(capabilities); From e38f7e1ca3c2cb82220c67dc5923a73fa418fcba Mon Sep 17 00:00:00 2001 From: titusfortner Date: Tue, 31 Mar 2020 16:38:44 -0500 Subject: [PATCH 09/22] fix incorrect constants --- .../android/AndroidMobileOptions.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index 598aa2e56..60e537039 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -736,27 +736,27 @@ public int getChromedriverPort() { * * @param ports is the list of ports for Appium to use with Chromedrivers. * @return this MobileOptions, for chaining. - * @see AndroidMobileCapabilityType#BUILD_TOOLS_VERSION + * @see AndroidMobileCapabilityType#CHROMEDRIVER_PORTS */ public AndroidMobileOptions setChromedriverPorts(List ports) { - return amend(AndroidMobileCapabilityType.BUILD_TOOLS_VERSION, ports); + return amend(AndroidMobileCapabilityType.CHROMEDRIVER_PORTS, ports); } /** * Get the valid ports for Appium to use for communication with Chromedrivers. * * @return list of Integers for the valid ports for Appium to use for communication with Chromedrivers. - * @see AndroidMobileCapabilityType#BUILD_TOOLS_VERSION + * @see AndroidMobileCapabilityType#CHROMEDRIVER_PORTS */ public Object getChromedriverPorts() { - return getCapability(AndroidMobileCapabilityType.BUILD_TOOLS_VERSION); + return getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_PORTS); } /** * Set the app to bypass automatic Chromedriver configuration and use the version that comes downloaded with Appium. * * @return this MobileOptions, for chaining. - * @see AndroidMobileCapabilityType#CHROMEDRIVER_DISABLE_BUILD_CHECK + * @see AndroidMobileCapabilityType#CHROMEDRIVER_USE_SYSTEM_EXECUTABLE */ public AndroidMobileOptions setChromedriverUseSystemExecutable() { return setChromedriverUseSystemExecutable(true); @@ -767,20 +767,20 @@ public AndroidMobileOptions setChromedriverUseSystemExecutable() { * * @param bool when true uses the version of Chromedriver that comes with Appium. * @return this MobileOptions, for chaining. - * @see AndroidMobileCapabilityType#CHROMEDRIVER_DISABLE_BUILD_CHECK + * @see AndroidMobileCapabilityType#CHROMEDRIVER_USE_SYSTEM_EXECUTABLE */ public AndroidMobileOptions setChromedriverUseSystemExecutable(boolean bool) { - return amend(AndroidMobileCapabilityType.CHROMEDRIVER_DISABLE_BUILD_CHECK, bool); + return amend(AndroidMobileCapabilityType.CHROMEDRIVER_USE_SYSTEM_EXECUTABLE, bool); } /** * Get whether to bypass automatic Chromedriver configuration and use the version that comes downloaded with Appium. * * @return true if using the version of Chromedriver that comes with Appium. - * @see AndroidMobileCapabilityType#CHROMEDRIVER_DISABLE_BUILD_CHECK + * @see AndroidMobileCapabilityType#CHROMEDRIVER_USE_SYSTEM_EXECUTABLE */ public boolean doesChromedriverUseSystemExecutable() { - return (boolean) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_DISABLE_BUILD_CHECK); + return (boolean) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_USE_SYSTEM_EXECUTABLE); } /** @@ -788,20 +788,20 @@ public boolean doesChromedriverUseSystemExecutable() { * * @param opts is the chromeoptions for ChromeDriver. * @return this MobileOptions, for chaining. - * @see AndroidMobileCapabilityType#CHROMEDRIVER_EXECUTABLE_DIR + * @see AndroidMobileCapabilityType#CHROME_OPTIONS */ public AndroidMobileOptions setChromeOptions(ChromeOptions opts) { - return amend(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE_DIR, opts); + return amend(AndroidMobileCapabilityType.CHROME_OPTIONS, opts); } /** * Get the chromeOptions capability for ChromeDriver. * * @return ChromeOptions set for use with ChromeDriver. - * @see AndroidMobileCapabilityType#CHROMEDRIVER_EXECUTABLE_DIR + * @see AndroidMobileCapabilityType#CHROME_OPTIONS */ public Object getChromeOptions() { - return getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE_DIR); + return getCapability(AndroidMobileCapabilityType.CHROME_OPTIONS); } /** From d11428b1fce2a41cedff906c55d2c030dda2899c Mon Sep 17 00:00:00 2001 From: titusfortner Date: Wed, 1 Apr 2020 11:31:18 -0500 Subject: [PATCH 10/22] user needs to be able to pass in int to capability and have it handled correctly --- .../android/AndroidMobileOptions.java | 48 ++++++++++++------- .../java_client/remote/MobileOptions.java | 6 ++- .../android/AndroidOptionsTest.java | 2 +- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index 60e537039..226e04957 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -62,8 +62,10 @@ public AndroidMobileOptions setAdbExecTimeout(Duration duration) { * @see AndroidMobileCapabilityType#ADB_EXEC_TIMEOUT */ public Duration getAdbExecTimeout() { - Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.ADB_EXEC_TIMEOUT); - return Duration.ofMillis(duration); + Object duration = getCapability(AndroidMobileCapabilityType.ADB_EXEC_TIMEOUT); + Integer integer = (Integer) duration; + Long value = Long.valueOf(integer); + return Duration.ofMillis(value); } /** @@ -178,8 +180,10 @@ public AndroidMobileOptions setAndroidDeviceReadyTimeout(Duration duration) { * @see AndroidMobileCapabilityType#ANDROID_DEVICE_READY_TIMEOUT */ public Duration getAndroidDeviceReadyTimeout() { - Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.ANDROID_DEVICE_READY_TIMEOUT); - return Duration.ofSeconds(duration); + Object duration = getCapability(AndroidMobileCapabilityType.ANDROID_DEVICE_READY_TIMEOUT); + Integer integer = (Integer) duration; + Long value = Long.valueOf(integer); + return Duration.ofSeconds(value); } /** @@ -242,8 +246,10 @@ public AndroidMobileOptions setAndroidInstallTimeout(Duration duration) { * @see AndroidMobileCapabilityType#ANDROID_INSTALL_TIMEOUT */ public Duration getAndroidInstallTimeout() { - Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.ANDROID_INSTALL_TIMEOUT); - return Duration.ofMillis(duration); + Object duration = getCapability(AndroidMobileCapabilityType.ANDROID_INSTALL_TIMEOUT); + Integer integer = (Integer) duration; + Long value = Long.valueOf(integer); + return Duration.ofMillis(value); } /** @@ -379,8 +385,10 @@ public AndroidMobileOptions setAppWaitDuration(Duration duration) { * @see AndroidMobileCapabilityType#APP_WAIT_DURATION */ public Duration getAppWaitDuration() { - Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.APP_WAIT_DURATION); - return Duration.ofMillis(duration); + Object duration = getCapability(AndroidMobileCapabilityType.APP_WAIT_DURATION); + Integer integer = (Integer) duration; + Long value = Long.valueOf(integer); + return Duration.ofMillis(value); } /** @@ -484,8 +492,10 @@ public AndroidMobileOptions setAutoWebviewTimeout(Duration duration) { * @see AndroidMobileCapabilityType#AUTO_WEBVIEW_TIMEOUT */ public Duration getAutoWebviewTimeout() { - Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.AUTO_WEBVIEW_TIMEOUT); - return Duration.ofMillis(duration); + Object duration = getCapability(AndroidMobileCapabilityType.AUTO_WEBVIEW_TIMEOUT); + Integer integer = (Integer) duration; + Long value = Long.valueOf(integer); + return Duration.ofMillis(value); } /** @@ -548,8 +558,10 @@ public AndroidMobileOptions setAvdLaunchTimeout(Duration duration) { * @see AndroidMobileCapabilityType#AVD_LAUNCH_TIMEOUT */ public Duration getAvdLaunchTimeout() { - Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.AVD_LAUNCH_TIMEOUT); - return Duration.ofMillis(duration); + Object duration = getCapability(AndroidMobileCapabilityType.AVD_LAUNCH_TIMEOUT); + Integer integer = (Integer) duration; + Long value = Long.valueOf(integer); + return Duration.ofMillis(value); } /** @@ -570,8 +582,10 @@ public AndroidMobileOptions setAvdReadyTimeout(Duration duration) { * @see AndroidMobileCapabilityType#AVD_READY_TIMEOUT */ public Duration getAvdReadyTimeout() { - Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.AVD_READY_TIMEOUT); - return Duration.ofMillis(duration); + Object duration = getCapability(AndroidMobileCapabilityType.AVD_READY_TIMEOUT); + Integer integer = (Integer) duration; + Long value = Long.valueOf(integer); + return Duration.ofMillis(value); } /** @@ -822,8 +836,10 @@ public AndroidMobileOptions setDeviceReadyTimeout(Duration duration) { * @see AndroidMobileCapabilityType#DEVICE_READY_TIMEOUT */ public Duration getDeviceReadyTimeout() { - Integer duration = (Integer) getCapability(AndroidMobileCapabilityType.DEVICE_READY_TIMEOUT); - return Duration.ofSeconds(duration); + Object duration = getCapability(AndroidMobileCapabilityType.AVD_READY_TIMEOUT); + Integer integer = (Integer) duration; + Long value = Long.valueOf(integer); + return Duration.ofSeconds(value); } /** diff --git a/src/main/java/io/appium/java_client/remote/MobileOptions.java b/src/main/java/io/appium/java_client/remote/MobileOptions.java index 41adafe07..1f79b3cb8 100644 --- a/src/main/java/io/appium/java_client/remote/MobileOptions.java +++ b/src/main/java/io/appium/java_client/remote/MobileOptions.java @@ -353,8 +353,10 @@ public T setNewCommandTimeout(Duration duration) { * @see MobileCapabilityType#NEW_COMMAND_TIMEOUT */ public Duration getNewCommandTimeout() { - Integer duration = (Integer) getCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT); - return Duration.ofSeconds(duration); + Object duration = getCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT); + Integer integer = (Integer) duration; + Long value = Long.valueOf(integer); + return Duration.ofSeconds(value); } /** diff --git a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java index 38c2cba01..515ccdd06 100644 --- a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java +++ b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java @@ -44,7 +44,7 @@ public void acceptsExistingCapabilities() { MutableCapabilities capabilities = new MutableCapabilities(); capabilities.setCapability("deviceName", "Pixel"); capabilities.setCapability("platformVersion", "10"); - capabilities.setCapability("newCommandTimeout", Duration.ofSeconds(60)); + capabilities.setCapability("newCommandTimeout", 60); androidMobileOptions = new AndroidMobileOptions(capabilities); From c5fbb3dc67a0891a002bbca235595fe13a8c3351 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Wed, 1 Apr 2020 11:36:29 -0500 Subject: [PATCH 11/22] all ports as Integers --- .../android/AndroidMobileOptions.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index 226e04957..e1076136f 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -75,18 +75,18 @@ public Duration getAdbExecTimeout() { * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#ADB_PORT */ - public AndroidMobileOptions setAdbPort(String port) { + public AndroidMobileOptions setAdbPort(Integer port) { return amend(AndroidMobileCapabilityType.ADB_PORT, port); } /** * Get the port used to connect to the ADB server. * - * @return String of the port used to connect to the ADB server. + * @return Integer of the port used to connect to the ADB server. * @see AndroidMobileCapabilityType#ADB_PORT */ - public String getAdbPort() { - return (String) getCapability(AndroidMobileCapabilityType.ADB_PORT); + public Integer getAdbPort() { + return (Integer) getCapability(AndroidMobileCapabilityType.ADB_PORT); } /** @@ -731,7 +731,7 @@ public String getChromedriverExecutableDir() { * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#CHROMEDRIVER_PORT */ - public AndroidMobileOptions setChromedriverPort(int port) { + public AndroidMobileOptions setChromedriverPort(Integer port) { return amend(AndroidMobileCapabilityType.CHROMEDRIVER_PORT, port); } @@ -742,7 +742,7 @@ public AndroidMobileOptions setChromedriverPort(int port) { * @see AndroidMobileCapabilityType#CHROMEDRIVER_PORT */ public int getChromedriverPort() { - return (int) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_PORT); + return (Integer) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_PORT); } /** @@ -1567,18 +1567,18 @@ public boolean doesSkipUnlock() { * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#SYSTEM_PORT */ - public AndroidMobileOptions setSystemPort(String port) { + public AndroidMobileOptions setSystemPort(Integer port) { return amend(AndroidMobileCapabilityType.SYSTEM_PORT, port); } /** * Get the port used to connect to the driver. * - * @return String of the port used to connect to the driver. + * @return Integer of the port used to connect to the driver. * @see AndroidMobileCapabilityType#SYSTEM_PORT */ - public String getSystemPort() { - return (String) getCapability(AndroidMobileCapabilityType.SYSTEM_PORT); + public Integer getSystemPort() { + return (Integer) getCapability(AndroidMobileCapabilityType.SYSTEM_PORT); } /** @@ -1724,17 +1724,17 @@ public boolean doesUseKeystore() { * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#WEBVIEW_DEVTOOLS_PORT */ - public AndroidMobileOptions setWebviewDevtoolsPort(String port) { + public AndroidMobileOptions setWebviewDevtoolsPort(Integer port) { return amend(AndroidMobileCapabilityType.WEBVIEW_DEVTOOLS_PORT, port); } /** * Get the TCP port for communication with the webview. * - * @return String of the TCP port for communication with the webview. + * @return Integer of the TCP port for communication with the webview. * @see AndroidMobileCapabilityType#WEBVIEW_DEVTOOLS_PORT */ - public String getWebviewDevtoolsPort() { - return (String) getCapability(AndroidMobileCapabilityType.WEBVIEW_DEVTOOLS_PORT); + public Integer getWebviewDevtoolsPort() { + return (Integer) getCapability(AndroidMobileCapabilityType.WEBVIEW_DEVTOOLS_PORT); } } From aefbb791e8aa89af4d7592050f21f012e6ba35e0 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Wed, 1 Apr 2020 12:40:43 -0500 Subject: [PATCH 12/22] fix port tests --- .../java_client/android/AndroidOptionsTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java index 515ccdd06..f33ca217d 100644 --- a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java +++ b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java @@ -231,7 +231,7 @@ public void setsAndroidStringCapabilities() { uninstallPackages.add("io.appium.example1"); uninstallPackages.add("io.appium.example2"); - androidMobileOptions.setAdbPort("1234") + androidMobileOptions.setAdbPort(1234) .setAndroidCoverage("com.my.Pkg/com.my.Pkg.instrumentation.MyInstrumentation") .setAndroidCoverageEndIntent("com.example.pkg.END_EMMA") .setAndroidDeviceSocket("chrome_devtools_remote") @@ -259,13 +259,13 @@ public void setsAndroidStringCapabilities() { .setNetworkSpeed("hscsd") .setOptionalIntentArguments("--esn 2222") .setRemoteAdbHost("192.168.0.101") - .setSystemPort("8201") + .setSystemPort(8201) .setUninstallOtherPackages(uninstallPackages) .setUnlockKey("1111") .setUnlockType("password") - .setWebviewDevtoolsPort("9543"); + .setWebviewDevtoolsPort(9543); - assertEquals("1234", androidMobileOptions.getAdbPort()); + assertEquals(Integer.valueOf(1234), androidMobileOptions.getAdbPort()); assertEquals("com.my.Pkg/com.my.Pkg.instrumentation.MyInstrumentation", androidMobileOptions.getAndroidCoverage()); assertEquals("com.example.pkg.END_EMMA", androidMobileOptions.getAndroidCoverageEndIntent()); assertEquals("chrome_devtools_remote", androidMobileOptions.getAndroidDeviceSocket()); @@ -293,11 +293,11 @@ public void setsAndroidStringCapabilities() { assertEquals("hscsd", androidMobileOptions.getNetworkSpeed()); assertEquals("--esn 2222", androidMobileOptions.getOptionalIntentArguments()); assertEquals("192.168.0.101", androidMobileOptions.getRemoteAdbHost()); - assertEquals("8201", androidMobileOptions.getSystemPort()); + assertEquals(Integer.valueOf(8201), androidMobileOptions.getSystemPort()); assertEquals(uninstallPackages, androidMobileOptions.getUninstallOtherPackages()); assertEquals("1111", androidMobileOptions.getUnlockKey()); assertEquals("password", androidMobileOptions.getUnlockType()); - assertEquals("9543", androidMobileOptions.getWebviewDevtoolsPort()); + assertEquals(Integer.valueOf(9543), androidMobileOptions.getWebviewDevtoolsPort()); } @Test From d07e5a90450067208a5cf64e81d742b269505c63 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Wed, 1 Apr 2020 12:43:27 -0500 Subject: [PATCH 13/22] finally fix duration implementation --- .../android/AndroidMobileOptions.java | 26 +++++++++++- .../java_client/remote/MobileOptions.java | 3 ++ .../android/AndroidOptionsTest.java | 41 +++++++++++-------- 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index e1076136f..95eb8659e 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -63,6 +63,9 @@ public AndroidMobileOptions setAdbExecTimeout(Duration duration) { */ public Duration getAdbExecTimeout() { Object duration = getCapability(AndroidMobileCapabilityType.ADB_EXEC_TIMEOUT); + if (duration.getClass().isAssignableFrom(Long.class)) { + return Duration.ofMillis((Long) duration); + } Integer integer = (Integer) duration; Long value = Long.valueOf(integer); return Duration.ofMillis(value); @@ -181,6 +184,9 @@ public AndroidMobileOptions setAndroidDeviceReadyTimeout(Duration duration) { */ public Duration getAndroidDeviceReadyTimeout() { Object duration = getCapability(AndroidMobileCapabilityType.ANDROID_DEVICE_READY_TIMEOUT); + if (duration.getClass().isAssignableFrom(Long.class)) { + return Duration.ofSeconds((Long) duration); + } Integer integer = (Integer) duration; Long value = Long.valueOf(integer); return Duration.ofSeconds(value); @@ -247,6 +253,9 @@ public AndroidMobileOptions setAndroidInstallTimeout(Duration duration) { */ public Duration getAndroidInstallTimeout() { Object duration = getCapability(AndroidMobileCapabilityType.ANDROID_INSTALL_TIMEOUT); + if (duration.getClass().isAssignableFrom(Long.class)) { + return Duration.ofMillis((Long) duration); + } Integer integer = (Integer) duration; Long value = Long.valueOf(integer); return Duration.ofMillis(value); @@ -386,6 +395,9 @@ public AndroidMobileOptions setAppWaitDuration(Duration duration) { */ public Duration getAppWaitDuration() { Object duration = getCapability(AndroidMobileCapabilityType.APP_WAIT_DURATION); + if (duration.getClass().isAssignableFrom(Long.class)) { + return Duration.ofMillis((Long) duration); + } Integer integer = (Integer) duration; Long value = Long.valueOf(integer); return Duration.ofMillis(value); @@ -493,6 +505,9 @@ public AndroidMobileOptions setAutoWebviewTimeout(Duration duration) { */ public Duration getAutoWebviewTimeout() { Object duration = getCapability(AndroidMobileCapabilityType.AUTO_WEBVIEW_TIMEOUT); + if (duration.getClass().isAssignableFrom(Long.class)) { + return Duration.ofMillis((Long) duration); + } Integer integer = (Integer) duration; Long value = Long.valueOf(integer); return Duration.ofMillis(value); @@ -559,6 +574,9 @@ public AndroidMobileOptions setAvdLaunchTimeout(Duration duration) { */ public Duration getAvdLaunchTimeout() { Object duration = getCapability(AndroidMobileCapabilityType.AVD_LAUNCH_TIMEOUT); + if (duration.getClass().isAssignableFrom(Long.class)) { + return Duration.ofMillis((Long) duration); + } Integer integer = (Integer) duration; Long value = Long.valueOf(integer); return Duration.ofMillis(value); @@ -583,6 +601,9 @@ public AndroidMobileOptions setAvdReadyTimeout(Duration duration) { */ public Duration getAvdReadyTimeout() { Object duration = getCapability(AndroidMobileCapabilityType.AVD_READY_TIMEOUT); + if (duration.getClass().isAssignableFrom(Long.class)) { + return Duration.ofMillis((Long) duration); + } Integer integer = (Integer) duration; Long value = Long.valueOf(integer); return Duration.ofMillis(value); @@ -836,7 +857,10 @@ public AndroidMobileOptions setDeviceReadyTimeout(Duration duration) { * @see AndroidMobileCapabilityType#DEVICE_READY_TIMEOUT */ public Duration getDeviceReadyTimeout() { - Object duration = getCapability(AndroidMobileCapabilityType.AVD_READY_TIMEOUT); + Object duration = getCapability(AndroidMobileCapabilityType.DEVICE_READY_TIMEOUT); + if (duration.getClass().isAssignableFrom(Long.class)) { + return Duration.ofSeconds((Long) duration); + } Integer integer = (Integer) duration; Long value = Long.valueOf(integer); return Duration.ofSeconds(value); diff --git a/src/main/java/io/appium/java_client/remote/MobileOptions.java b/src/main/java/io/appium/java_client/remote/MobileOptions.java index 1f79b3cb8..231c1d048 100644 --- a/src/main/java/io/appium/java_client/remote/MobileOptions.java +++ b/src/main/java/io/appium/java_client/remote/MobileOptions.java @@ -354,6 +354,9 @@ public T setNewCommandTimeout(Duration duration) { */ public Duration getNewCommandTimeout() { Object duration = getCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT); + if (duration.getClass().isAssignableFrom(Long.class)) { + return Duration.ofSeconds((Long) duration); + } Integer integer = (Integer) duration; Long value = Long.valueOf(integer); return Duration.ofSeconds(value); diff --git a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java index f33ca217d..f67a91021 100644 --- a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java +++ b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java @@ -191,11 +191,7 @@ public void setsAndroidBooleanValueCapabilities() { } @Test - public void setsAndroidNumberCapabilities() { - List ports = new ArrayList<>(); - ports.add(9000); - ports.add(9005); - + public void setsDurationCapabilities() { androidMobileOptions.setAdbExecTimeout(Duration.ofMillis(500)) .setAndroidDeviceReadyTimeout(Duration.ofSeconds(5)) .setAndroidInstallTimeout(Duration.ofSeconds(300)) @@ -203,10 +199,7 @@ public void setsAndroidNumberCapabilities() { .setAutoWebviewTimeout(Duration.ofMillis(9000)) .setAvdLaunchTimeout(Duration.ofMillis(10000)) .setAvdReadyTimeout(Duration.ofMillis(11000)) - .setChromedriverPort(1234) - .setChromedriverPorts(ports) - .setDeviceReadyTimeout(Duration.ofSeconds(33)) - .setRemoteAppsCacheLimit(4); + .setDeviceReadyTimeout(Duration.ofSeconds(33)); assertEquals(Duration.ofMillis(500), androidMobileOptions.getAdbExecTimeout()); assertEquals(Duration.ofSeconds(5), androidMobileOptions.getAndroidDeviceReadyTimeout()); @@ -215,10 +208,28 @@ public void setsAndroidNumberCapabilities() { assertEquals(Duration.ofMillis(9000), androidMobileOptions.getAutoWebviewTimeout()); assertEquals(Duration.ofMillis(10000), androidMobileOptions.getAvdLaunchTimeout()); assertEquals(Duration.ofMillis(11000), androidMobileOptions.getAvdReadyTimeout()); + assertEquals(Duration.ofSeconds(33), androidMobileOptions.getDeviceReadyTimeout()); + } + + @Test + public void setsAndroidNumberCapabilities() { + List ports = new ArrayList<>(); + ports.add(9000); + ports.add(9005); + + androidMobileOptions.setAdbPort(1234) + .setChromedriverPort(1234) + .setChromedriverPorts(ports) + .setRemoteAppsCacheLimit(4) + .setSystemPort(8201) + .setWebviewDevtoolsPort(9543); + + assertEquals(Integer.valueOf(1234), androidMobileOptions.getAdbPort()); assertEquals(1234, androidMobileOptions.getChromedriverPort()); assertEquals(ports, androidMobileOptions.getChromedriverPorts()); - assertEquals(Duration.ofSeconds(33), androidMobileOptions.getDeviceReadyTimeout()); assertEquals(4, androidMobileOptions.getRemoteAppsCacheLimit()); + assertEquals(Integer.valueOf(8201), androidMobileOptions.getSystemPort()); + assertEquals(Integer.valueOf(9543), androidMobileOptions.getWebviewDevtoolsPort()); } @Test @@ -231,8 +242,7 @@ public void setsAndroidStringCapabilities() { uninstallPackages.add("io.appium.example1"); uninstallPackages.add("io.appium.example2"); - androidMobileOptions.setAdbPort(1234) - .setAndroidCoverage("com.my.Pkg/com.my.Pkg.instrumentation.MyInstrumentation") + androidMobileOptions.setAndroidCoverage("com.my.Pkg/com.my.Pkg.instrumentation.MyInstrumentation") .setAndroidCoverageEndIntent("com.example.pkg.END_EMMA") .setAndroidDeviceSocket("chrome_devtools_remote") .setAndroidInstallPath("/sdcard/Downloads/") @@ -259,13 +269,10 @@ public void setsAndroidStringCapabilities() { .setNetworkSpeed("hscsd") .setOptionalIntentArguments("--esn 2222") .setRemoteAdbHost("192.168.0.101") - .setSystemPort(8201) .setUninstallOtherPackages(uninstallPackages) .setUnlockKey("1111") - .setUnlockType("password") - .setWebviewDevtoolsPort(9543); + .setUnlockType("password"); - assertEquals(Integer.valueOf(1234), androidMobileOptions.getAdbPort()); assertEquals("com.my.Pkg/com.my.Pkg.instrumentation.MyInstrumentation", androidMobileOptions.getAndroidCoverage()); assertEquals("com.example.pkg.END_EMMA", androidMobileOptions.getAndroidCoverageEndIntent()); assertEquals("chrome_devtools_remote", androidMobileOptions.getAndroidDeviceSocket()); @@ -293,11 +300,9 @@ public void setsAndroidStringCapabilities() { assertEquals("hscsd", androidMobileOptions.getNetworkSpeed()); assertEquals("--esn 2222", androidMobileOptions.getOptionalIntentArguments()); assertEquals("192.168.0.101", androidMobileOptions.getRemoteAdbHost()); - assertEquals(Integer.valueOf(8201), androidMobileOptions.getSystemPort()); assertEquals(uninstallPackages, androidMobileOptions.getUninstallOtherPackages()); assertEquals("1111", androidMobileOptions.getUnlockKey()); assertEquals("password", androidMobileOptions.getUnlockType()); - assertEquals(Integer.valueOf(9543), androidMobileOptions.getWebviewDevtoolsPort()); } @Test From 988ac1b6f32ecd98473984423b83c655afbd557e Mon Sep 17 00:00:00 2001 From: titusfortner Date: Wed, 1 Apr 2020 12:44:23 -0500 Subject: [PATCH 14/22] chromedriver ports can have nested lists --- .../io/appium/java_client/android/AndroidMobileOptions.java | 4 ++-- .../io/appium/java_client/android/AndroidOptionsTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index 95eb8659e..3e27a3c30 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -773,14 +773,14 @@ public int getChromedriverPort() { * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#CHROMEDRIVER_PORTS */ - public AndroidMobileOptions setChromedriverPorts(List ports) { + public AndroidMobileOptions setChromedriverPorts(List ports) { return amend(AndroidMobileCapabilityType.CHROMEDRIVER_PORTS, ports); } /** * Get the valid ports for Appium to use for communication with Chromedrivers. * - * @return list of Integers for the valid ports for Appium to use for communication with Chromedrivers. + * @return list of Integers or Array of Integers for the valid ports to use for communication with Chromedrivers. * @see AndroidMobileCapabilityType#CHROMEDRIVER_PORTS */ public Object getChromedriverPorts() { diff --git a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java index f67a91021..19bee1d41 100644 --- a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java +++ b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java @@ -213,7 +213,7 @@ public void setsDurationCapabilities() { @Test public void setsAndroidNumberCapabilities() { - List ports = new ArrayList<>(); + List ports = new ArrayList<>(); ports.add(9000); ports.add(9005); From 442a779be5af241ccab7bed0f25c36abc7633fc6 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Wed, 1 Apr 2020 12:45:05 -0500 Subject: [PATCH 15/22] Selenium automatically converts ChromeOptions to goog:chromeOptions --- .../io/appium/java_client/android/AndroidMobileOptions.java | 2 +- .../java/io/appium/java_client/android/AndroidOptionsTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index 3e27a3c30..c1d65d8d3 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -836,7 +836,7 @@ public AndroidMobileOptions setChromeOptions(ChromeOptions opts) { * @see AndroidMobileCapabilityType#CHROME_OPTIONS */ public Object getChromeOptions() { - return getCapability(AndroidMobileCapabilityType.CHROME_OPTIONS); + return getCapability(ChromeOptions.CAPABILITY); } /** diff --git a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java index 19bee1d41..1366c2b97 100644 --- a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java +++ b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java @@ -87,7 +87,7 @@ public void acceptsChromeDriverOptions() { ChromeOptions chromeOptions = new ChromeOptions(); androidMobileOptions.setChromeOptions(chromeOptions); - assertEquals(chromeOptions, androidMobileOptions.getChromeOptions()); + assertNotNull(androidMobileOptions.getChromeOptions()); } @Test From f240eafaae1383c891403199a6990e3654462158 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Wed, 1 Apr 2020 12:48:22 -0500 Subject: [PATCH 16/22] remove unicodeKeyboard accessors --- .../android/AndroidMobileOptions.java | 31 ------------------- .../android/AndroidOptionsTest.java | 4 --- 2 files changed, 35 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index c1d65d8d3..5897313ed 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -1605,37 +1605,6 @@ public Integer getSystemPort() { return (Integer) getCapability(AndroidMobileCapabilityType.SYSTEM_PORT); } - /** - * Set the app to enable Unicode input. - * - * @return this MobileOptions, for chaining. - * @see AndroidMobileCapabilityType#UNICODE_KEYBOARD - */ - public AndroidMobileOptions setUnicodeKeyboard() { - return setUnicodeKeyboard(true); - } - - /** - * Set whether to enable Unicode input. - * - * @param bool when true enables Unicode input. - * @return this MobileOptions, for chaining. - * @see AndroidMobileCapabilityType#UNICODE_KEYBOARD - */ - public AndroidMobileOptions setUnicodeKeyboard(boolean bool) { - return amend(AndroidMobileCapabilityType.UNICODE_KEYBOARD, bool); - } - - /** - * Get whether to enable Unicode input. - * - * @return true if Unicode input is enabled. - * @see AndroidMobileCapabilityType#UNICODE_KEYBOARD - */ - public boolean isUnicodeKeyboard() { - return (boolean) getCapability(AndroidMobileCapabilityType.UNICODE_KEYBOARD); - } - /** * Set the list of packages to uninstall before installing apks. * diff --git a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java index 1366c2b97..7e0f7c2a8 100644 --- a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java +++ b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java @@ -112,7 +112,6 @@ public void setsAndroidBooleanDefaultCapabilities() { .setSkipDeviceInitialization() .setSkipLogcatCapture() .setSkipUnlock() - .setUnicodeKeyboard() .setUseKeystore(); assertTrue(androidMobileOptions.doesAllowTestPackages()); @@ -135,7 +134,6 @@ public void setsAndroidBooleanDefaultCapabilities() { assertTrue(androidMobileOptions.doesSkipDeviceInitialization()); assertTrue(androidMobileOptions.doesSkipLogcatCapture()); assertTrue(androidMobileOptions.doesSkipUnlock()); - assertTrue(androidMobileOptions.isUnicodeKeyboard()); assertTrue(androidMobileOptions.doesUseKeystore()); } @@ -162,7 +160,6 @@ public void setsAndroidBooleanValueCapabilities() { .setSkipDeviceInitialization(false) .setSkipLogcatCapture(false) .setSkipUnlock(false) - .setUnicodeKeyboard(false) .setUseKeystore(false); assertFalse(androidMobileOptions.doesAllowTestPackages()); @@ -186,7 +183,6 @@ public void setsAndroidBooleanValueCapabilities() { assertFalse(androidMobileOptions.doesSkipDeviceInitialization()); assertFalse(androidMobileOptions.doesSkipLogcatCapture()); assertFalse(androidMobileOptions.doesSkipUnlock()); - assertFalse(androidMobileOptions.isUnicodeKeyboard()); assertFalse(androidMobileOptions.doesUseKeystore()); } From 1453a1a68bbe5b472568b94e8c4830430ce494d1 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Wed, 1 Apr 2020 13:05:21 -0500 Subject: [PATCH 17/22] change uninstallOtherApps from List to String --- .../java_client/android/AndroidMobileOptions.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index 5897313ed..04220d05c 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -1606,24 +1606,24 @@ public Integer getSystemPort() { } /** - * Set the list of packages to uninstall before installing apks. + * Set the packages to uninstall before installing apks. * - * @param packages is the list of packages to uninstall before installing apks. + * @param packages is the String of comma separated packages to uninstall before installing apks. * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#UNINSTALL_OTHER_PACKAGES */ - public AndroidMobileOptions setUninstallOtherPackages(List packages) { + public AndroidMobileOptions setUninstallOtherPackages(String packages) { return amend(AndroidMobileCapabilityType.UNINSTALL_OTHER_PACKAGES, packages); } /** * Get the list of packages to uninstall before installing apks. * - * @return list of Strings for packages to uninstall before installing apks. + * @return String of package(s) to uninstall before installing apks. * @see AndroidMobileCapabilityType#UNINSTALL_OTHER_PACKAGES */ - public Object getUninstallOtherPackages() { - return getCapability(AndroidMobileCapabilityType.UNINSTALL_OTHER_PACKAGES); + public String getUninstallOtherPackages() { + return (String) getCapability(AndroidMobileCapabilityType.UNINSTALL_OTHER_PACKAGES); } /** From 1df2efd08b737ca1c942d244dc17ae2cd92b9d97 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Wed, 1 Apr 2020 13:12:35 -0500 Subject: [PATCH 18/22] change otherApps from List to String --- .../appium/java_client/remote/MobileOptions.java | 8 ++++---- .../java_client/android/AndroidOptionsTest.java | 15 ++++----------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/main/java/io/appium/java_client/remote/MobileOptions.java b/src/main/java/io/appium/java_client/remote/MobileOptions.java index 231c1d048..1833c0027 100644 --- a/src/main/java/io/appium/java_client/remote/MobileOptions.java +++ b/src/main/java/io/appium/java_client/remote/MobileOptions.java @@ -421,18 +421,18 @@ public ScreenOrientation getOrientation() { * @return this MobileOptions, for chaining. * @see MobileCapabilityType#OTHER_APPS */ - public T setOtherApps(List apps) { + public T setOtherApps(String apps) { return amend(MobileCapabilityType.OTHER_APPS, apps); } /** * Get the list of apps to install before running a test. * - * @return apps to install. + * @return String of apps to install. * @see MobileCapabilityType#OTHER_APPS */ - public Object getOtherApps() { - return getCapability(MobileCapabilityType.OTHER_APPS); + public String getOtherApps() { + return (String) getCapability(MobileCapabilityType.OTHER_APPS); } /** diff --git a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java index 7e0f7c2a8..1e4af649b 100644 --- a/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java +++ b/src/test/java/io/appium/java_client/android/AndroidOptionsTest.java @@ -55,14 +55,11 @@ public void acceptsExistingCapabilities() { @Test public void acceptsMobileCapabilities() throws MalformedURLException { - ArrayList paths = new ArrayList<>(); - paths.add("/path/to/app.apk"); - androidMobileOptions.setApp(new URL("http://example.com/myapp.apk")) .setAutomationName(AutomationName.ANDROID_UIAUTOMATOR2) .setPlatformVersion("10") .setDeviceName("Pixel") - .setOtherApps(paths) + .setOtherApps("/path/to/app.apk") .setLocale("fr_CA") .setUdid("1ae203187fc012g") .setOrientation(ScreenOrientation.LANDSCAPE) @@ -73,7 +70,7 @@ public void acceptsMobileCapabilities() throws MalformedURLException { assertEquals(AutomationName.ANDROID_UIAUTOMATOR2, androidMobileOptions.getAutomationName()); assertEquals("10", androidMobileOptions.getPlatformVersion()); assertEquals("Pixel", androidMobileOptions.getDeviceName()); - assertEquals(paths, androidMobileOptions.getOtherApps()); + assertEquals("/path/to/app.apk", androidMobileOptions.getOtherApps()); assertEquals("fr_CA", androidMobileOptions.getLocale()); assertEquals("1ae203187fc012g", androidMobileOptions.getUdid()); assertEquals(ScreenOrientation.LANDSCAPE, androidMobileOptions.getOrientation()); @@ -234,10 +231,6 @@ public void setsAndroidStringCapabilities() { chromedriverArgs.add("--disable-gpu"); chromedriverArgs.add("--disable-web-security"); - List uninstallPackages = new ArrayList<>(); - uninstallPackages.add("io.appium.example1"); - uninstallPackages.add("io.appium.example2"); - androidMobileOptions.setAndroidCoverage("com.my.Pkg/com.my.Pkg.instrumentation.MyInstrumentation") .setAndroidCoverageEndIntent("com.example.pkg.END_EMMA") .setAndroidDeviceSocket("chrome_devtools_remote") @@ -265,7 +258,7 @@ public void setsAndroidStringCapabilities() { .setNetworkSpeed("hscsd") .setOptionalIntentArguments("--esn 2222") .setRemoteAdbHost("192.168.0.101") - .setUninstallOtherPackages(uninstallPackages) + .setUninstallOtherPackages("io.appium.ex1,io.appium.ex2") .setUnlockKey("1111") .setUnlockType("password"); @@ -296,7 +289,7 @@ public void setsAndroidStringCapabilities() { assertEquals("hscsd", androidMobileOptions.getNetworkSpeed()); assertEquals("--esn 2222", androidMobileOptions.getOptionalIntentArguments()); assertEquals("192.168.0.101", androidMobileOptions.getRemoteAdbHost()); - assertEquals(uninstallPackages, androidMobileOptions.getUninstallOtherPackages()); + assertEquals("io.appium.ex1,io.appium.ex2", androidMobileOptions.getUninstallOtherPackages()); assertEquals("1111", androidMobileOptions.getUnlockKey()); assertEquals("password", androidMobileOptions.getUnlockType()); } From 38b3ef0b6cd9acb4eb2b058e6938dfd7344e3da2 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Wed, 1 Apr 2020 13:18:53 -0500 Subject: [PATCH 19/22] fix test --- .../io/appium/java_client/remote/MobileOptionsTest.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java b/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java index 63e35b12a..27e1a6765 100644 --- a/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java +++ b/src/test/java/io/appium/java_client/remote/MobileOptionsTest.java @@ -46,14 +46,11 @@ public void acceptsExistingCapabilities() { @Test public void acceptsMobileCapabilities() throws MalformedURLException { - ArrayList paths = new ArrayList<>(); - paths.add("/path/to/app.apk"); - mobileOptions.setApp(new URL("http://example.com/myapp.apk")) .setAutomationName(AutomationName.ANDROID_UIAUTOMATOR2) .setPlatformVersion("10") .setDeviceName("Pixel") - .setOtherApps(paths) + .setOtherApps("/path/to/app.apk") .setLocale("fr_CA") .setUdid("1ae203187fc012g") .setOrientation(ScreenOrientation.LANDSCAPE) @@ -64,7 +61,7 @@ public void acceptsMobileCapabilities() throws MalformedURLException { assertEquals(AutomationName.ANDROID_UIAUTOMATOR2, mobileOptions.getAutomationName()); assertEquals("10", mobileOptions.getPlatformVersion()); assertEquals("Pixel", mobileOptions.getDeviceName()); - assertEquals(paths, mobileOptions.getOtherApps()); + assertEquals("/path/to/app.apk", mobileOptions.getOtherApps()); assertEquals("fr_CA", mobileOptions.getLocale()); assertEquals("1ae203187fc012g", mobileOptions.getUdid()); assertEquals(ScreenOrientation.LANDSCAPE, mobileOptions.getOrientation()); From ffd26c45f4e724b828427a9cbbefa33a806d3a6f Mon Sep 17 00:00:00 2001 From: titusfortner Date: Wed, 1 Apr 2020 13:20:10 -0500 Subject: [PATCH 20/22] fix parameter name --- .../io/appium/java_client/android/AndroidMobileOptions.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index 04220d05c..6d64c14e6 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -1369,12 +1369,12 @@ public boolean isNoSign() { /** * Set the additional intent arguments that will be used to start activity. * - * @param speed is the additional intent arguments that will be used to start activity. + * @param arguments is the additional intent arguments that will be used to start activity. * @return this MobileOptions, for chaining. * @see AndroidMobileCapabilityType#OPTIONAL_INTENT_ARGUMENTS */ - public AndroidMobileOptions setOptionalIntentArguments(String speed) { - return amend(AndroidMobileCapabilityType.OPTIONAL_INTENT_ARGUMENTS, speed); + public AndroidMobileOptions setOptionalIntentArguments(String arguments) { + return amend(AndroidMobileCapabilityType.OPTIONAL_INTENT_ARGUMENTS, arguments); } /** From 3b1c230c7263b9ad03ba16d7a7b511ea204905e1 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Wed, 1 Apr 2020 15:48:06 -0500 Subject: [PATCH 21/22] don't need to use Object when return value is a List --- .../appium/java_client/android/AndroidMobileOptions.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java index 6d64c14e6..f92c045f7 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileOptions.java @@ -647,8 +647,8 @@ public AndroidMobileOptions setChromedriverArgs(List args) { * @return list of String arguments to be passed to the chromedriver binary when it's run by Appium. * @see AndroidMobileCapabilityType#CHROMEDRIVER_ARGS */ - public Object getChromedriverArgs() { - return getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_ARGS); + public List getChromedriverArgs() { + return (List) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_ARGS); } /** @@ -783,8 +783,8 @@ public AndroidMobileOptions setChromedriverPorts(List ports) { * @return list of Integers or Array of Integers for the valid ports to use for communication with Chromedrivers. * @see AndroidMobileCapabilityType#CHROMEDRIVER_PORTS */ - public Object getChromedriverPorts() { - return getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_PORTS); + public List getChromedriverPorts() { + return (List) getCapability(AndroidMobileCapabilityType.CHROMEDRIVER_PORTS); } /** From 4aa554c7b23a883dae92299c959a34b50a506dc2 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Wed, 1 Apr 2020 16:29:12 -0500 Subject: [PATCH 22/22] fix ios options test --- src/test/java/io/appium/java_client/ios/IOSOptionsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/appium/java_client/ios/IOSOptionsTest.java b/src/test/java/io/appium/java_client/ios/IOSOptionsTest.java index 94ea95f8c..dd391097d 100644 --- a/src/test/java/io/appium/java_client/ios/IOSOptionsTest.java +++ b/src/test/java/io/appium/java_client/ios/IOSOptionsTest.java @@ -37,7 +37,7 @@ public void acceptsExistingCapabilities() { MutableCapabilities capabilities = new MutableCapabilities(); capabilities.setCapability("deviceName", "Pixel"); capabilities.setCapability("platformVersion", "10"); - capabilities.setCapability("newCommandTimeout", Duration.ofSeconds(60)); + capabilities.setCapability("newCommandTimeout", 60); iosMobileOptions = new IOSMobileOptions(capabilities);