iOS: How to get device system language from terminal - ios

I am trying to retrieve the current system language of the device connected to my MacBook from command line.
Do you have any suggestions?

ideviceinfo -q com.apple.international -k Language
Try ideviceinfo.

you can system language by this
let pre = Locale.preferredLanguages[0]

Related

Original error: Error Domain=com.facebook.WebDriverAgent Code=1 "Keyboard is not present" UserInfo={NSLocalizedDescription=Keyboard is not present}

My simulator keyboard is not displayed when I run my test cases from automation. I keep getting the below error.
Original error: Error Domain=com.facebook.WebDriverAgent Code=1 "Keyboard is not present" UserInfo={NSLocalizedDescription=Keyboard is not present}
When my automation code opens simulator, In simulator->Harward->keyboard->Connect Hardware keyboard is unchecked and I am not able to check that.
And when I open simulator normally I get the simulator keyboard and the option Connect hardware Keyboard is also selected by default
Can anyone help me out here.
Its a known WebDriverAgent issue: https://github.com/facebook/WebDriverAgent/issues/574
Try to update to latest Appium server 1.9.1 to use latest version of WebDriverAgent.
If it won't help, follow suggestion from the last comment on github issue:
Before tests run bash script defaults write com.apple.iphonesimulator ConnectHardwareKeyboard -bool no
Add turn off hardware keyboard as it seems to cause failures occasionally
error occurs when you use ios simulator.
To solve this use below command for enabling keyboard.
1.Restart your Xcode if it's already open. Then use below keys.
For opening and closing keyboard you can use below shortcuts.
cmd + k
If first option doesn't work then set below capabilities in your script.
2.
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("Connect Hardware Keyboard", true);
OR
(capabilities.setCapability(IOSMobileCapabilityType.CONNECT_HARDWARE_KEYBOARD, true)
I resolved this on iOS for Mobile app automation using Appium
Set the capability to not refer to the hardware keyboard
cap.setCapability("connectHardwareKeyboard", false);
While executing the case, where you need to access the keyboard use
driver.findElementByXPath("****** ").sendKeys("Text")
After getting the input on the field, dismiss the keyboard
driver.hideKeyboard()
iOS:Real Device
Uninstall if you have installed any third party keyboards, keep only the default keyboard on the device.
Re run the same code. It should work now
Uninstalling Keyboards: Settings ->General -> KeyBoards-> Edit

--enable-precise-memory-info is not working on Mobile Chrome

Under the:
chrome://flags
I didn't find
--enable-precise-memory-info
Trying to run with:
ChromeOptions options = new ChromeOptions();
options.AddArguments("--enable-precise-memory-info");
also had no success, values are rounded.
Is it even possible?
Let me know if you need more details on this issue
Note: it's not about desktop, mobile chrome browse only!
One way of doing this is with adb
adb -s $deviceId shell am start -n com.android.chrome/com.google.android.apps.chrome.Main argv --args='--enable-precise-memory-info'
to obtain device id:
adb devices
But it wouldn't save flag for the next session, and if you are trying to open it with SeleniumWebDriver probably it should be done with DesiredCapabilities through adding ChromeOptions... but it's still a question how to do it
Currently an Appium 1.7.1 issue.
Follow fix progress here:
https://github.com/appium/appium/issues/9838

UI test fails when it types text into a text view when run by an Xcode bot

I have the following XCTest UI test that types text into a text view.
let textView = app.textViews.elementBoundByIndex(0)
textView.tap()
textView.typeText("Hello world")
When run as an Xcode bot it shows the following error for the typeText call.
Assertion: UI Testing Failure - failed: Timed out waiting for key event to complete
Interestingly, when I run it manually from the Xcode on the same computer the test passes. This test also passed in Xcode bot before upgrade to Xcode 7.1 / iOS 9.1. What can be the source of the problem?
Here is an isolated demo with the UI test:
https://github.com/exchangegroup/UITestTextViewDemo
iOS 9.1 Simulator, OS X 10.11.1 (15B42), Xcode 7.1 (7B91b), OS X Server 5.0.15 (15S4033)
Reported to Apple.
I believe the underlying issue is that "Connect Hardware Keyboard" is turned on by default. Even if you turn it off for the main user, the _xcsbuildd user still uses the default. I was able to solve the problem by adding a pre test action to the scheme with the following script:
if [ `defaults read com.apple.iphonesimulator ConnectHardwareKeyboard` -eq 1 ]
then
defaults write com.apple.iphonesimulator ConnectHardwareKeyboard -bool false
killall "Simulator"
fi
I found a solution for my case and I hope it helps you as well.
In my setUp() and tearDown() (seems redundant I know) I put XCUIApplication().terminate(). This is ensuring that the app is terminated before running the next test and it seems to be doing the job.
override func setUp() {
XCUIApplication().terminate()
super.setUp()
continueAfterFailure = false
XCUIApplication().launch()
}
override func tearDown() {
super.tearDown()
XCUIApplication().terminate()
}
I filed a bug with Apple but for the time being this is getting me around the error that you were seeing. Hope that helps!
I found out another solution, since the one proposed by Konnor wasn't working for me: I was having a lot of problems using UITest on Xcode Bot, and the common symptom was that testing on simulator took a lot more time than on the local machine, so I thought that the _xcsbuildd user used to run the tests was in some way slowed down.
My solution is simple: just promote _xcsbuildd user to be a "normal" user. This has another advantage: if you want you can login with that user and see the tests run in the simulator during integration, so it is easier to debug!
Here is how I did it:
sudo dscl . -create /Users/_xcsbuildd UserShell /bin/bash
sudo dscl . -create /Users/_xcsbuildd FirstName Xcode
sudo dscl . -create /Users/_xcsbuildd LastName Server
sudo dscl . -create /Users/_xcsbuildd FullName "Xcode Server"
sudo dscl . -create /Users/_xcsbuildd PrimaryGroupID 20
Then change the password with:
sudo dscl . -passwd /Users/_xcsbuildd
I was not able to make the user show up in the fast login window, anyway you should see a "other user" where you can insert the username "_xcsbuildd" and the password you chose
I ran into this issue as well. I have written a UI test to capture screenshots with Snapshot (fastlane) and it runs fine on an iPad Air & Pro simulator. However, on an iPad Retina or iPad 2 simulator I get this error message, either running from command line or directly from Xcode.
A solution in my case was to add some sleep() functions between the typeText() statements and the error went away.
Edit: this only fixes running manually from Xcode, through command line it still causes a test failure. I also noticed that it works on all simulators for 64-bit devices, but not on earlier devices.
Edit 2: I found a way to work around this issue by using the iOS 9.0 simulator instead of iOS 9.3, as mentioned in this answer: https://stackoverflow.com/a/36334816/5334132. This seems a good workaround until it gets fixed in a new version of Xcode.
Other than connect hardware keyboard, none of these things really worked for me. What did work was turning off the Mac's screen saver and display sleep in system settings. My suspicion is the simulator performs oddly when the Mac is locked or doesn't have a monitor to draw to.
With those two settings off, I still get a few random UI test failures. Connecting hardware monitors or screen sharing so the simulator is drawn on screen somewhere seems to resolve those though.
I am using xcode 8.2.1 and running tests on ios 9.3 versions. One simple hack is to add a sleep for 2-5 secs after tapping on the text box and before typing on it. Though, this is not a permanent solution.
ANOTHER RELIABLE SOLUTION
Unselect all keyboard preferences in settings before running the tests.
"KeyboardAllowPaddle": false,
"KeyboardAssistant": false,
"KeyboardAutocapitalization": false,
"KeyboardAutocorrection": false,
"KeyboardCapsLock": false,
"KeyboardCheckSpelling": false,
"KeyboardPeriodShortcut": false,
"KeyboardPrediction": false,
"KeyboardShowPredictionBar": false

Error in using UIAutomatorviewer for testing Android app in Appium

I have to automate an Android application, I am doing the same through Appium.
The problem I am facing is after launching the Appium server, the app is getting installed in the emulator 4.4.2. To inspect the element I am using UIAutomatorviewer which comes default with SDK. But while inspecting the element of the app, I am getting the error:
Error obtaining UI hierarchy
Reason:Error while obtaining UI hierarchy XML file.com.android.ddmlb.SynchException.Remote object doesn't exist.
I tried to find the solution so that I can inspect the element so that I can script, but in vain.
Can someone please tell how to fix the issue so that I can inspect elements?
Is there any other way I can inspect element in the app apart from using UIAutomator viewer?
After my tryst with the uiautomator viewer i came to know that we get the error only when:
appium server is running and we try to capture the screenshot using uiautomatorviewer.
So, whenever you want to use uiautomatorviewer make sure that server is in stopped state.
I fixed the same issue by using following methods.
(1) Connect your Android device to your development machines;
(2) Go to command line in terminal or DOS command line for Windows;
(3) Using "adb shell" into your Android devices;
(4) Change the user to root by input "su root" in command line;
(5) Change the access right to /data/local/tmp by input "chmod 777 /data/local/tmp";
(6) Go back to uiautomatorviewer and do screen shot again, the error should be gone;
I guess there are some file can't be access if it doesn't own right in /data/local/tmp.
Make sure everything on your screen is static. And flashing input cursor is also not allowed. Any painting actions will stop uiautomator from dumping current UI.
You can test by using following adb command:
adb shell uiautomator dump /data/local/tmp/uidump.xml
if the message ERROR: could not get idle state. appears, you are suffering from this issue.
See lines 87 & 101 of DumpCommand:
try {
...
uiAutomation.waitForIdle(1000, 1000 * 10);
...
} catch (TimeoutException re) {
System.err.println("ERROR: could not get idle state.");
return;
}
Easiest solution..
Restart the device. Restart uiautomatorviewer.
Worked like a charm for me .... :P
Stop the Appium Server. Then try again. It works.
I had the same problem because I used "adbd insecure". So I just disabled "adbd insecure", and reload uiautomatorviewer, everything is OK.
In case of rooted devices: Enable the root access in developer options for adb. Restart adb as root
I have spent over a week to resolve this issue. When you connect your device and using ASM 3.0, when screen is projected open the UIAutomator to capture the current android screen. Without Appium it should capture. For use Android Studio instead of android sdk. Uninstall and reinstall Android Studio. It is working perfect for me now.
Answer to your question #2
You can inspect Android app directly from your real Android device.
You need to:
Connect Android device to your computer/laptop
Go to Android device Settings -> Enable Developer Options and Android debbuging
Please see here:
Start the app you wish to inspect in your Android device
Open up the Chrome browser on your computer/laptop and do a right click -> More Tools -> Inspect devices -> Click on your device -> (Click on Android device OK to authorize) -> Click Inspect
Please see here:
That's it. Hope it helps!
I got also the same issue (Also if Appium Server was not running). After switch, OFF / ON USB-Debugging was working for me.
I got it resolved
I closed the Appium Server running on my machine and opened it again.
Later open uiautomater, and it worked for me
The one that works is in this path:
Android/Sdk/tools/bin/uiautomatorviewer
Paste this in your terminal and it will run automator that works
we have to use device which has API level morethan 17 or jelly bean
Way to bypass the ERROR:
could not get idle state.
By using uiautomator to get uix and screenshot.
public class DeviceMethods extends UiAutomatorTestCase {
public void dump(){
try {
getUiDevice().dumpWindowHierarchy("window_dump.uix") ;
getUiDevice().takeScreenshot(new File("/data/local/tmp/window_dump.png"));
} catch (Exception e) {
}
}
you need to create the uiautomator jar and push it to /data/local/tmp
use this tutorial on how to use uiautomator
after you get the files just open them in uiautomatorviewer
What worked for me:
stop appium
open an emulator device (tested with Android 7.1.1)
go into settings > developer options > Enable view attribute inspection
open a shell on the computer, cmd or terminal depending on your OS
enter the following commands:
adb shell
su
cd /data
cd /local
chmod 777 tmp
start uiautomatorviewer
take an xml screenshot
"su chmod 777 /data/local/tmp" didnt work for me so I drilled down and it worked. I assume that you have to do this in an emulator and not a physical device unless the device is rooted. ¯ \ _ (ツ)_/¯
Lotsa Luck!
This happens because adb is using port and it's blocked by appium server.
I have found out best solution for this
Kill the adb.exe from taskbar processes and try launching uiautomatorviewer again
Check whether you have enabled these under "developer options" in the phone.
Verify apps via USB
View attribute inspection
USB debugging
1) stop appium Server
2) open an emulator device
3) go into settings > developer options > Enable view attribute inspection
4) developer options in invisible? Go into settings > Tap on About device/phone > Scroll down till the last option(Build number) > Continuously Tap on "Build number" for 7 times > you should get an Toast message "You're a developer" > come back from that screen > Go back into settings > Now you should see developer options Tap on it > Enable view attribute inspection
5) You should no more get this error message
Why don't you use appium inspector instead? You can download it and follow instructions from here
try switching Off and then ON the USB debugging option.. this work for me

FDT 5 Max Milestone 8 / Debug Connection from iOS Device

What is the current workflow for receiving debug traces from an iOS device within the FDT console?
How do you customize the ADT args?
*
${package} ${target} ${connection} ${sampler} ${market} ${special} ${legacyaot} ${signing} ${provision} ${output} ${content} ${icons} ${platformsdk}*
I tried to replace ${connection} with -connect MY_IP_ADDRESS, but that does not do the trick, the debugger dialog window does not pop up. Is an ANT-script still the only solution?
Thanks in advance!
Found it – even if you create an ad-hoc development .ipa file, you have to replace the ${target} with -target ipa-debug.
I still don't receive debug traces after starting the fdt debugger and then starting the app on the device. Any tipps are welcome.
WIFI is enabled, USB cable is connected.
Okay, so easy – while focussing on the 'deploy' on device tab I totally missed the new part of FDT 5 Max in the debug configuration for the main class.

Resources