I have a virtual robot running and I want to send a voice input to them with text, like the way that the dialog window in Choregraphe works. How can I do this using a Python script?
I am running the virtual robot from the terminal using the naoqi-bin application on Ubuntu with something like naoqi-bin -b 127.0.0.1 -p 9001
Thanks.
You can call ALDialog.forceInput; something like this:
qiapp = qi.Application()
qiapp.start()
session = qiapp.session
session.service("ALDialog").forceInput("hey virtual nao how are you doing?")
Related
I would like to run local server tests on real devices using appium. Are there any existing capabilities which i could use to do so ? I basicall have a server running on a port on my local machine but would like to test it on a real device.
For example i want to test http://locahost:3000 on a real device. how can this port be avaialble on the real mobile device? I know Browser/Stack or Sauce labs implement this using their own local binaries. Can this be done with appium ?
Note: I have my grid setup ready with real devices configured and i can run other tests normally.
EDIT: Just to make it clear and to avoid irrelevant answers. I am looking for something like network sharing from the machine where the tests are invoked to run on real devices. i want to to test a server which is hosted locally and not avilable on the internet.
In order to test on real device, your device must be connected to your computer. To run the test on multiple devices, multiple instance of appium server must be run. You must use device udid in DesiredCapabilities to run the test on the specific device.
To run the appium server in port 3000 you must run the following command in terminal:
appium -a 127.0.0.1 -p 3000 --session-override
Appium server must be installed in your system in order to run above command.
Using port 3000 is not recommended as other program may be using the same port.
To run the app in real device you can define your AppiumDriver and DesiredCapabilities like following:
public class Test1(){
public static AppiumDriver<MobileElement> driver;
public static void main(String[] args){
DesiredCapabilities caps=new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.UDID, "your device udid");
caps.setCapability(MobileCapabilityType.DEVICE_NAME, "android device");
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
caps.setCapability("appPackage", appPackage);
caps.setCapability("appActivity", appActivity);
caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
try{
driver == new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:3000/wd/hub"), caps);
}catch(Exception e){
e.printStackTrace();
}
}
Please check below link to apply proxy settings in Appium.
https://www.npmjs.com/package/appium-proxy#setup-a-basic-appium-proxy
I want to make an app.which can start and stop adb daemon which i want to run on Google Nexus 7(Android 5.0.1).
I downloaded the nexus 7 source code and created an app. in packages/app folder and built it in system/priv-app.
I am using following code for starting and stoping adb daemon :
Runtime.getRuntime().exec("setprop service.adb.tcp.port 5555");
Runtime.getRuntime().exec("stop adbd");
Runtime.getRuntime().exec("start adbd");
But its not working.
It works fine on an emulator(Android 4.4), but not on the device.
Can any one please suggest if anything more needs to be done for the above code to work on device.
I am having the
whole system code.
Thanks
I'm using Java but this isn't necessarily a Java question. Google's "java-compat" image is Debian (3.16.7-ckt20-1+deb8u3~bpo70+1 (2016-01-19)).
Here is my Dockerfile:
FROM gcr.io/google_appengine/java-compat
RUN apt-get -qqy update && apt-get qqy install curl xvfb x11vnc
RUN mkdir -p ~/.vnc
RUN x11vnc -storepasswd xxxxxxxx ~/.vnc/passwd
EXPOSE 5900
ADD . /app
And in the Admin Console I created a firewall rule to open up 5900. And lastly I am calling the vnc server itself in the "_ah/start" startup hook with this command:
x11vnc -forever -usepw -create
All seems to be setup correctly but I'm unable to connect with TightVNC. I use the public (ephemeral) IP address for the instance I find in the Admin Console followed by ::5900 (TightVNC requires two colons for some reason). I'm getting a message that the server refused the connection. And indeed when I try to telnet to port 5900 it's blocked.
Next I SSH into the container machine and when I test the port on the container with wget xxx.xxx.xxx.xxx:5900 I get a connection. So it seems to me the container is not accepting connections on port 5900. Am I getting this right? Is it possible to open up ports and route my VNC client into the docker container? Any help appreciated.
Why I can't use Compute Engine. Just to preempt some comments about using google's Compute Engine environment instead of Managed VMs. I make heavy use of the Datastore and Task Queues in my code. I don't think those can run (or run natively/efficiently) on Compute Engine. But I may pose that as a separate question.
Update: Per Paul in the comments... having learned some of the docker terminology: Can I publish a port on the container in Google's environment?
Out of curiosity - why are you trying to VNC into your instances? If it's just for management purposes, you can SSH into Managed VM instances.
That having been said - you can use the network/forwarded_ports config to route traffic from the VM to the application container:
network:
forwarded_ports:
- 5900
instance_tag: vnc
Put that in your app.yaml, and re-deploy your app. You'll also need to open the port in your firewall (if you intend on accessing this from the public internet):
gcloud compute firewall-rules create default-allow-vnc \
--allow tcp:5900 \
--target-tags vnc \
--description "Allow vnc traffic on port 5900"
Hope this helps!
Using: selenium webdriver, rubygems, appium, android and ios devices
The app I am testing has a button which becomes enabled only when connected to a specific wireless network. I'd like to create a script which will check if the button is active or not
vKioskStatus = element.enabled?
puts(vKioskStatus)
If it is not active, then I'd like to change wifi networks. Is that possible to automate changing networks on a mobile device?
UPDATE
I'm receiving the following error when trying to use getNetworkConnection. Is there a require I need to add?
<main>': undefined method `getNetworkConnection' for #<Selenium::WebDriver::Driver:0x..fe1a5511e browser=:firefox> (NoMethodError)
Here's my code:
require 'rubygems'
require 'selenium-webdriver'
require 'uri'
require 'appium_lib'
require_relative 'AndroidLib'
cButton = Buttons.new
driver = Selenium::WebDriver.for(:remote, :url => "http://127.0.0.1:4723/wd/hub") # Works for Android
sleep(5)
bob = driver.getNetworkConnection()
puts bob
you can toggle the wifi connection in Android (not possible in iOS) using the below appium commands,
To enable flight mode :
# Python
def enableFlightMode(self,context):
driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE)
driver.implicitly_wait(10)
if driver.network_connection == 1:
self.report_pass("The network connection is disabled in the mobile and flight mode is active.")
else:
self.report_fail("The flight mode is not active yet!")
And to disable flight mode:
def enableFlightMode(self,context):
driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE)
driver.implicitly_wait(10)
if driver.network_connection == 1:
self.report_pass("The network connection is disabled in the mobile and flight mode is active.")
else:
self.report_fail("The flight mode is not active yet!")
You can achieve this by accessing all available wifi networks using Shell Script. It means you need to write logic of firing ADB/Shell commands through your code.Connecting to wifi using adb shell
On your button click you can fire command to connect to desired wifi network.
Yes, it is possible to change the network using Appium. Look here
I am using below adb commands to turn on & off WiFi/data.And it is working fine.
Turn on wifi - adb shell am start -n io.appium.settings/.Settings -e wifi on
Turn off WiFi - adb shell am start -n io.appium.settings/.Settings -e wifi off
Turn on mobile data - adb shell am start -n io.appium.settings/.Settings -e data on
Turn off mobile data - adb shell am start -n io.appium.settings/.Settings -e data off
You can get/change network connection settings through AndroidDriver. However, it works only for Android version less than 5.
AppiumDriver<WebElement> driver = new AndroidDriver<WebElement>(new URL("..."), caps);
NetworkConnectionSetting networkConnection = new NetworkConnectionSetting(false, true, false); // airplane mode, wiif, data
networkConnection.setData(true); // enable mobile data
networkConnection.setWifi(false); // close wifi
((AndroidDriver<WebElement>)driver).setNetworkConnection(networkConnection);
networkConnection = ((AndroidDriver<WebElement>)driver).getNetworkConnection();
This ADB command will certainly switch off your wifi :
adb shell am broadcast -a io.appium.settings.wifi --es setstatus disable
To turn it on use :
adb shell am broadcast -a io.appium.settings.wifi --es setstatus enable
OR
Try this code -
self.driver.open_notifications()
self.driver.find_element_by_xpath('//android.widget.Switch[#content-desc="Airplane mode"]').click()
self.driver.back()
Give me a thumps up if it works for you
If I have Android phone connected via USB, how do I know the commands I can send via USB to get Information like
core temperature of the device,
version of android,
power consumption details, etc.
Can I then use ADB logs, command to interact with Android mobile. Please may i know the process apart from commands if I have to send commands via ADB.
To get information from an android device, you can always use the following tools.
Use utilities like dumpsys or getprop.
Query from /sys/ or /proc/.
Eventually all utilities, fetch information from /proc or /sys, so you can directly investigate into these.
You could use dumpsys tools to get information:
Core temperature of the device
I'm not sure, what exactly do you mean by core temperature of the device.
Temperature of Device: Note
$ adb shell cat /sys/class/thermal/thermal_zone0/temp
37
Temperature of Battery:
$ adb shell cat /sys/class/power_supply/battery/device/power_supply/battery/temp
285
or
$ adb shell dumpsys battery
Current Battery Service state:
AC powered: false
USB powered: true
Wireless powered: false
status: 2
health: 2
present: true
level: 15
scale: 100
voltage: 3768
current now: -357254
temperature: 285 # <---- Temparature.
technology: Li-ion
Version of android
$ getprop ro.build.version.release
4.4.4 #<--- Android Kitkat 4.4.4
I'm not completely sure how you can get exact information:
You could start with,
$ adb shell dumpsys power
POWER MANAGER (dumpsys power)
Power Manager State:
....
Note: Results on a Linux System.
$ acpi -t # <--- apci power utility/tool.
Thermal 0: ok, 29.8 degrees C
Thermal 1: ok, 27.8 degrees C
$ cat /sys/class/thermal/thermal_zone0/temp
27800
I want this to be executed every 50 ms ?
You could write a script with above commands, that queries every 50ms.
Set-up ADB on Windows ?
A quick Google search should help you out.
Set Up Android ADB On Windows
To make proper use of Dumpsys,
See What's the Android ADB shell "dumpsys" tool and what are its benefits?
http://android-test-tw.blogspot.in/2012/10/dumpsys-information-android-open-source.html
Getprop : Android ADB commands to get the device properties
I hope this should give you a good start.
You will get the Android device properties using getprop command.
Please go through this blog .Here I am listing some of the major ADB commands. Feel free to ask doubts regarding these commands.