appium troubleshooting
TRANSCRIPT
Appium TroubleshootingAdi Ben Aroya
Sep 2016
On The Agenda
Appium Installation & Supporting Versions
Appium Server Launching (manually & programmatically)
Parallel Run
Device Vs Emulators
Log Handling
Native & WebApp Tip
Q&A
Install & Run Challenges
★ Supporting versions & stability
★ Running Appium programmatically
★ Maintaining long stable run
★ Rerun of server (Best Practice)
★ Parallel run on multiple devices
Appium - Supporting versions & stability
High sensitivity to supporting versions.
Appium Server Version Node.js npm Appium Java Client
1.5.3 0.12.13 2.15.1 2.0, 3.41, 4.0.0
Install Steps for 1.5.3
npm uninstall npm -gbrew install npm -g
brew install node
npm install [email protected]
npm update [email protected]
Appium Server – Environment Setup
In Terminal write “Android” and make sure following components installed:
● Android SDK Tools
● Android SDK Platform-Tools
● Android SDK Build-Tools
Environmental Settings:
#JAVA_HOMEexport JAVA_HOME=`/usr/libexec/java_home -v 1.7`export PATH="/usr/local/bin:$PATH"
#ANDROIDexport ANDROID_HOME="/usr/local/Cellar/android-sdk"export ANDROID_SDK=$ANDROID_HOME
Appium Server – Run Command & switches
For iOS Run
appium --address 127.0.0.1 --port 4723 --log appiumClientLog.log --session-override
For Android
appium --address 127.0.0.1 --port 4724 --bootstrap 5724 -U 192.168.56.101:5555 --log appiumDriverLog.log --session-override
appium --address 127.0.0.1 --port 4723 --bootstrap 5723 -U 192.168.56.102:5555 --log appiumClientLog.log --session-override
Appium - Server Arguments
--address 127.0.0.1
Run Appium server on remote or locally
--port 4723 --bootstrap 5723
Port to listen on & (Android-only) port to use on device to talk to Appium
--log appiumClientLog.log
Also send log output to this file
--session-override
Enables session override (clobbering)
Appium – Server launching programmatically (logic)
Is Appium Active?
Launch Appium Server
Appium Connect
boolean isAppiumActive = isAppiumActive();if(!isAppiumActive)
RunAppiumServer(); else
Appium.connect();
Appium - Run Server
<< Don't write logs to console (due to slowness & buffer fill-up)
protected void runAppiumServer() throws ConnectionException, Exception { try {
StringBuffer runAppiumCommand = new StringBuffer("appium --address " ... + " --log appiumClientLog.log --session-override --native-instruments-lib");
if (this instanceof ClientAndroidImpl) runAppiumCommand.append(" -U " + getTaxiAppium.getUuid());
runAppiumCommand.append(" > /dev/null 2>&1 &");
CliCommand cmd = new CliCommand(runAppiumCommand.toString());cmd.setTimeout(3000);//default 30seccmd.setIgnoreErrors(true);terminal.handleCliCommand("Run appium server", cmd);
} catch (Exception e) {report.report("Unable to run Appium - need to stop the run! " + e.getMessage());throw new SeverFailedToDeployed("failed to run Appium : " + e.getMessage());
}}
Appium – Disable On screen Logs
--log appiumClientLog.log
Also send log output to this file
runAppiumCommand.append(" > /dev/null 2>&1 &");
How to hide terminal output when executing a command?
Add to your server arguments the following:
appium --address 127.0.0.1 --port 4723 --bootstrap 5723 --log appiumClientLog.log --session-override > /dev/null 2>&1 &
Run server string will look like:
Don't Forget:
Appium – Parallel Devices Run Android
--port 4723 --bootstrap 5723
--port 4724 --bootstrap 5724
Android Device 1
Android Device 2
Make Sure to use Different Port Id and BootStrap ID for each device.
For Android Add UUID for real device or IP for simulator: -U 192.168.56.101:5555
For iOS the bootstrap flag can be dropped BUT still maintain deferent Port ID.
Appium - init process takes too long
public DesiredCapabilities setCapabilities() { ...
if (!reset) {capabilities.setCapability("fullReset", false);capabilities.setCapability("noReset", true);
} ...}
Add to capabilities:
In the event that Login (for exmp') shouldn't be tested...
FullReset - Open app with last used screen
NoReset - Do not install app from path if app is already installed.
Appium - Scrolling problem
private void swipeDown() throws Exception { int screenWidth = Integer.valueOf(appiumDriver.manage().window().getSize().width); int screenHeight = Integer.valueOf(appiumDriver.manage().window().getSize().height); appiumDriver.swipe((screenWidth / 2), ((int) (screenHeight * 0.8)), (screenWidth / 2), ((int) (screenHeight * 0.2)), 2000);}
Swipe What?
public void swipeByElement(GetTaxiButton gettaxiBtn,boolean left) throws Exception { int ScreenY = findElementYOnScreen(gettaxiBtn);//"+orderTaxiForm.getLine().getName()+" if (left)
appiumDriver.swipe(Integer.valueOf((int) (appiumDriver.manage().window().getSize().width * 0.2)),ScreenY,Integer.valueOf((int) (appiumDriver.manage().window().getSize().width *0.8)),ScreenY,2000);
elseappiumDriver.swipe(Integer.valueOf((int) (appiumDriver.manage().window().getSize().width *0.8)),ScreenY,Integer.valueOf((int) (appiumDriver.manage().window().getSize().width * 0.2)),ScreenY,2000);
}
Speed -> Not to slow not to fast (2000 Good balance)By screen size for full scroll all the way.
Appium – Selenium Trick
// AbstractPage - passing to it the WebDriver appiumPageImpl= new AppiumDriverPageImpl(driver)
appiumDriver = appium.connect();WebDriver driver = appiumDriver;
Appium - Web Driver Page Impl class
The Implementor for IOS platform - Appium
• Example of using the obj “appiumPageImpl” to click on btn using selenium Api • The Method iphoneButtons.get() transform the the getTaxiButton into our the WebLocatore Object
appiumPageImpl.clickOnButton.
(iphoneButtons.get(getTaxiButton.name()));
Inside AbstractPage Class
The Implementor for IOS platform - Appium
• Example of using the obj “appiumPageImpl” to click on Mouse using Events selenium Api
appiumPageImpl.selectAutoCompleteOptionWithMouse(iphoneButtons.get(GetTaxiButtonOK.name()));
● QA Testers
● Automation developers● Architect
● Fullstack Web Developer
● iOS / Android
● Product Manager
● Product Analyst
● BI
● DevOps
● Big Data
● UX/UI designers
WE ARE HIRING
Thanks!