My goal is a setup where I keep Appium and Android emulator running on a remote Ubuntu Virtual Private Server and the test code running Selenium on a local machine.
In theory it should not be a problem with this setup:
appium_capabilities = {
'automationName': 'Appium',
'platformName': 'Android',
'deviceName': 'Android',
'app': 'APK_PATH'
}
vps_url = "THIS IS MY VPS IP"
appium_driver =
AppiumDriver(command_executor=vps_url+'/wd/hub',
desired_capabilities=appium_capabilities)
appium_driver.find_element(...)
appium_driver.quit()
Will it work or do I waste my time trying? I am asking because I cannot find any tutorials about it. If yes, how will the configuration need to be?
It actually will work (Appium server + emulator on remote server, tests code on other machine) but you need to make sure your apk is on remote server and the path to apk is the valid absolute path on that remote machine.
If you feel in this requirement, it will works smoothly - I'm doing the same :)
While creating session you need to provide remote server URL and correct port server is listening to.
Related
I try to use SSH on Android the first time, i had read a lot about it but i cant find much, only from Android to Computer. Maybe someone can help me here:)
I have coded an APK for my own Android Device wheres create an SSH Connection over my PHP Script using Proxy Server.
I use an Debian VPS as Proxy Server. With this IP, the Android creates an Proxy.
Now i use this Comment:
ssh -N -L 34836:127.0.0.1:34836 newgenerateduser#23.106.XXX.XX
Port is generated also random every time i create an new proxy over PHP Script.
I use now an Virtual Machine with Ubuntu and enter the Comment in my Terminal with the Passwort after asking.
I start my VNC Client and want get remote Control over my Android device using VNC or SSH with this IP and Port:
127.0.0.1:34836
I got this Message:
lxs#linux-virtual-machine:~$ ssh -N -L 34836:127.0.0.1:34836 newgenerateduser#23.106.XXX.XX
newgenerateduser#23.106.XXX.XX's password:
channel 2: open failed: connect failed: Connection refused
I also tried using localhost instead of IP.
There are special requirements for the Proxy Server? Or just Port blocking on it?
Thanks for your help!
I use couple of Android apps on daily bases, and it's very time consuming.
I want to somehow automatize the process.
The idea is to install some sort of emulator on the server, and program that emulator through some programming language to run the apps on the server when its needed.
I'm a web developer, I work with PHP, nodejs, python,
not really familiar with mobile space.
Is there any solution out there to do what I want?
I search around and found Appium but I'm not sure if it would do what I want.
Please note these apps don't have a public 'api' for me to use.
Also I only have remote access to server via 'ssh terminal', so solutions with 'GUI' dependency wont work for me.
You can use some emulator, like Bluestacks and then run a script to run apps and then use macro tool to emulate clicks in the games or apps
check this link for the macro tool in bluestacks : https://www.bluestacks.com/blog/bluestacks-exclusives/combo-key-bluestacks-record-replay-action-single-key-en.html
Or you can write a script which uses adb commands to run and control the app.
For example.
to run apps. adb shell am start -n com.android.settings/.Settings
this command will open the settings app in the emulator.
to send touch events you can use : adb shell input touch <x> <Y>
adb shell input keyevent <keycode> to send keycodes
I'm assuming that you want to automate native Android apps.
Short answer: Appium will be good solution for you.
On your remote server you will need:
Android SDK and Simulator
Python 2.7 installed
Appium server/node (install using node.js npm )
With everything installed you will be able to start Appium Nodes on your server and run Appium scripts against them.
I suggest using CI server of choise for automating this process. It should make starting your test trough ssh terminal easier / 100% automated.
I never used Selenium/Appium in python, so I can't really help you with Appium tests code examples, but I'm sure there are a lot of basic tutorials for python.
You must install AppiumServer and android sdk/simulator in the remote server. I am going to show how it can be done in java. Hope you can convert it into javascript code.
Check the ip Address of your remote server using ipconfig
Start your appium server in the remote server
>appium -a "ip address of remote server" -p 4732 --session-override
Start the emulator in the remote server.
Define and initialize DesiredCapabilities and AppiumDriver in your code like following.
AppiumDriver<MobileElement> driver;
DesiredCapabilities caps= new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.DEVICE_NAME, "android device");
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
caps.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 300);
caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
caps.setCapability("appPackage", "enter your appPackage");
caps.setCapability("appActivity", "enter your appActivity");
driver= new AndroidDriver<MobileElement>(new URL("remote server ip address" + ":4732/wd/hub"), caps);
Make sure both device are in the same network. you must get response while pinging to the remote server ip address
I'm using Jenkins for continous integration on an android emulator to run instrumentation tests with the espresso framework. Unfortunately the server is not able to connect to the emulator. I have a master instance which delegates the push events from GitHub to the slave instance where the android sdk is installed. I installed the android-emulator-plugin and configured it like described. At first the Jenkins starts the emulator, but it cannot connect to it afterwards. This is the result:
I also cannot connect to the emulator when I'm on the slave machine. But if I use 127.0.0.1 instead of localhost the adb tool can connect to the emulator:
Is it possible to use 127.0.0.1 instead of localhost with the android-emulator-plugin? I already specified the enviorment variables $ANDROID_AVD_DEVICE and $ANDROID_SERIAL with no result. Any ideas?
I was fighting with it whole day. Just try to comment ipv6 in your /etc/hosts.
I fixed the problem by myself. I have checked out a fork on GitHub, which uses 127.0.0.1 instead of localhost. This did work for connecting to the emulator but not for running the instrumentation tests. I do not use Jenkins plugins for the connection anymore. I make the build with a shell script which contains all commands to start the AVD and the gradle tasks. Works fine for me. But thank you for the advice. Maybe I will try to comment ipv6 aswell, if I have the time to work on the Jenkins.
New to Android, I have .Net webservices residing in my PC. when my Android application calls the webservice from emulator with IP address, it runs perfectly.
But running the same code in mobile does not work (mobile is connected to PC using USB cable). It shows server timeout error. Both phone and PC are on the same network.
I am unable to run - adb pull /data/anr/traces.txt. It says unrecognized command. I had Android studio installed but unable to find adb file.
So installed Android Sdk again: C:\Program Files\android-sdk-windows\tools - it says that adb file has moved to platform-tools. I tried various ways but no luck.
Any suggestions are welcome. Many thanks in advance.
If your web service is not hosted, you need to use localhost or 127.0.0.1 in your mobile app's URL IP address. Make sure they are in the same network
here is any configuration for this tools eclipse or wamp or android sdk to connect my mobile phone to wampserver?
i look this exemple in this site blow i just copy and paste the code in eclipse but the problem is how i can import and export data from my phone to database and Conversely ?
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
If I've understood correctly, you're running a wamp server locally on your computer and you'd like to access that server from your application. The general approach is similar to connecting to any other server, but you'd have to find the right IP-address to connect to. Try this:
First, make sure your server is up and running.
Second, access the server on your computer using one of two addresses:
If you're testing your app on the emulator (AVD), use this: 10.0.2.2, which translates to the localhost-address on your computer.
If you're testing your app on an actual device, you'd have to find your computer's IP-address. On linux, open a terminal and execute the command ifconfig. In windows, I believe it's ipconfig. Use the address listed under wlan0 -> inet addr.
Remember to append the port number your server is running on.
EDIT
Example, given port number is 80:
Emulator: 10.0.2.2:80
Device: 192.168.X.X:80