How does Flutter driver work with Android? - android-testing

In android world to run UI test with ADB, you need to execute this command
adb shell am instrument -w com.tarek360.sample.test
but before running this command you need to install your test package and main application Android package files (.apk files) to your current Android device or emulator, more info here.
Normally the APKs package names will be in the following format:
Main APK: com.tarek360.sample
Test APK: com.tarek360.sample.test
but in Flutter world, when I run flutter drive, for example, the following command:
flutter drive --target=test_driver/app.dart
I see only the main APK has installed and I don't see any test APK has installed on my device, I'm wondering how does Flutter Driver works with Android, it's important for me to understand because I have very customized CI and I build APKs in a completely different environment than the test runner environment.

Tests on your computer use Flutter Driver to connect to Flutter Driver Extension, that you must enable separately, inside your application using TCP and send commands to it using adb with port forwarding

Related

Build, deploy and run a Flutter app for iOS from Android Studio on a Linux computer using a remote Mac with an Xcode server or an SSH server?

I use a Debian Linux computer as my main development computer for Flutter apps for Android with Android Studio.
When I want to test an app on iOS, I need to pull the Flutter app source code from my source control system (GitLab) on my Apple macOS computer, build, deploy and run from there using Android Studio.
What I would like to do, is avoid the source control pull step in the process and initiate the iOS build, deploy and run on the Apple computer from the Android Studio on the Linux computer.
I consider the build, deploy and execute steps in Android studio as commands. I believe that those commands can be configured maybe through Gradle configuration files. If so, it should be possible to configure Android Studio and Gradle so that my Android Studio on Linux makes use of a remote Apple computer for the build, deploy and run either through an Xcode server or through an SSH server installed on the Mac.
At the moment, when I try a flutter build ios on my Linux machine, I get this expected error message:
Building for iOS is only supported on the Mac.
Does anyone have a solution to make this remote?
I know that Appollo does this for building apps. It's a python CLI tool that lets you connect to remote Macs. The CLI tool is open source so maybe you can find how they connect to the MacOS machines in their source code : https://github.com/Appollo-CLI/Appollo

How to connect flutter to Bluestacks emulator?

I'm setting up an Android device for flutter development and need to have a lightweight emulator. How do I connect bluestacks to flutter? Since the android studio is too slow for my machine and I only have an iPhone.
Yes, You can connect Flutter to Bluestacks.
You have to enable adb on Bluestacks' configurations, by following:
gear icon > Advanced configs > (marks as true: enable ADB connection)
after that, you must to restart your bluestacks, then open a terminal and go to your Android SDK folder:
%localappdata%/Android/Sdk/platform-tools/
then type the follow commands:
adb connect localhost:5555
So, by now if you type flutter devices you will get the emulator device name on the list, then you can run your apps on it
In this case what I would like to suggest you is to download GenyMotion.
Is a very lightweight emulator and it has its own plugin for Android Studio.
I was on a similar situation with an AMD processor and this was a really helpful way for me to test my apps.
Here is the URL for download: http://cloud.geny.io/
Steps
Install the latest version(4.180.10.1006) of bluestack
Open the bluestack
Enable the adb by setting>preferences>tick "Enable Android Debug Bridge"
Open the cmd
Create a flutter project by typing "flutter create [projectName]"
Access to your project folder by typing "cd projectName"
Run flutter app by typing "flutter run"
How to enable adb over bluestack
Step1 - Click the setting(gear)
Step2- Click the preference
Step3 - Scroll Down to Enable Android Debug Bridge
Hello, I hope it's not too late for you - but:
You can use sublime text as editor and for running your app.
You can use command prompt (cmd) on windows and as an emulator, you can use Genymotion.
It will fit for you if you need a light editor along with a good emulator that does not take too much RAM space.
I have tested it, and it was running perfectly.
However, the problem were flutter packages for sublime text(coding helper).
I couldn't find any packages for sublime text, only dart. You can update the question for further information.
I hope you understand this and it will help you.

Appium installation on Windows 7

I have tried to install Appium on Windows 7 for automated testing of Android mobile apps. but it failed.
Can you please let me know, if Appium could be installed on Windows 7 ?
If yes, can you please give any link or reference where I can find and follow the installation steps on Windows 7.
Yes, You can install Appium on Windows 7.
All you need is to install Appium for Windows along with android-sdk and Genymotion(for running your tests on simulators). You however wont be run your tests on ios as it requires xcode which is not present on Windows.
After you have installed Appium(via .exe or GUI) you'll have a folder created via name Appium (by default in Program Files(x86).
To start your appium server, simple type appium &.
In order to initialize Node/Grid, go to the path where the Appium folder is created and traverse to Appium\node_modules\appium\bin. Initialize your json config using node appium --nodeconfig commands.
You can download Appium for Windows directly from Appium's of cial website (http://appium.io/), or you can clone Appium from https://github.com/ appium/appium.git.
Just to ensure that we are ready to start with the Appium server, enter the following command on the Command Prompt:
node Appium-doctor
You don't need to download Node; you can get it from the Appium bundle. To run the Node commands, you need to set the path for Node (for example, C:\ AppiumForWindows). Before running the command, set the directory as C:\ AppiumForWindows\node_modules\appium\bin.

Problems by setting up Appium

I want to set up an Appium test automtion framework on Mac OS (El Capitan).
First, I want to run test automation by iOS simulator and the Appium test app UICatalog.
Currently I ran into some problems. Also I have to mention that I'm quite new to testing stuff...
What I have installed so far:
xCode 7.2.1
Appium GUI
Node.js
Java JDK 1.8.0_51
When I run the Appium Doctor by GUI there are no problems listed!
Question so far:
Is the Appium GUI the same as the npm installation like this
npm install -g appium
npm install wd
appium &
Do I still need the selenium package? Or does it come with the Appium GUI?
When I start Appium server by GUI I receive the following state:
Why does it get locked? What is missing?
Do I have to run xCode besides Appium server when I want to test an app?
How do I grant Appium access to the iOS simulator? Is this still necessary? I haven't get an authentification like this.
I hope anyone can give me some hints :).
I see your appium port is running on 4723. When you run your appium test scripts, which has port 4723 mentioned on your script itself. Your automated test cases would automatically run on the 4723.
Appium requires backend server port to be running. This way it communicates with your device.
The appium GUI is the Server GUI which shows what all happens in the back end when u trigger your script. All you need to do is , use the same port no in ur script while running,
eg:
iosDriver driver=new iosDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
I have done automation using Appium+Cucumber+Java so I had the same questions you had. Here are some answers for you based on my experience-
Appium Gui is not the same as npm. They are 2 separate components. Appium uses node.js framework. So you need to install Appium and node.js (npm) separately. The command you mentioned
npm install -g appium
would install the Appium server. To install the Appium GUI you need to download and install it from this link - http://appium.io/downloads.html
Follow these instructions where I give step by step instructions on how to set up Appium - http://www.rajsubra.com/2016/04/03/appiumjavacucumber-set-up-step-by-step-instructions/
If you follow the above steps you should be able to run tests via the iOS Simulator.
Also the state you mentioned in the screenshot with the Appium GUI is the normal expectations. It is just saying the Appium server started via the GUI and also gives you details on what simulator configuration has been selected.

iOS emulator no longer running from command line using phonegap

My iOS emulator is no longer opening when I run "phonegap run ios" in the terminal on Mac OS X. I receive no error messages and:
[phonegap] Platform "ios" deployed to emulator.
[phonegap] successfully installed onto emulator
While this is currently a known bug, you can run the emulate command more directly (note you need to build separately):
phonegap local build ios
/platforms/ios/cordova/emulate
You can also run the application using the same technique:
phonegap local build ios
/platforms/ios/cordova/run
NOTE: When using this method to run the app on your phone, the task might get stuck on the splash screen. To fix this, launch the Activity Monitor on your Mac and quit any processes with the name "ios-deploy". From there you can launch the application on your phone by clicking the application icon.
Or, you can even look inside the generated /platforms/ios folder and launch XCode project directly to test in an emulator or on your device. Open project and click the RUN button.
IMPORTANT: with all of the above methods, you MUST run the build command before running:
phonegap local build ios
Not really an answer, but I can say this is a known bug. Here is the bug so you can track it:
https://issues.apache.org/jira/browse/CB-5103
I only had this problem after upgrading to 3.1. I downgraded to 3.0 and it works more reliably:
npm uninstall -g phonegap
npm install -g phonegap#3.0
Also had to delete the platform/ios dir and plugins/ios.json and then run 'phonegap build ios' and 'phonegap run ios'

Resources