I'm using Appium on Mac OS with iPhone 5S with operation system 9.2.
When i'm trying to hide the Keyboard with the method:
driver.hidekeyboard();
Nothing happens and the application crash.
Need help please
Thanks
Ohad
If in case your application is crashing on when you are trying to hide the keyboard, then that could be a possible bug you are looking at and to understand the cause of that and get it fixed would be the topmost recommendation. Your statement
driver.hidekeyboard();
is good enough for what you desire out of the execution assuming the driver used is AppiumDriver or its subclass.
Also if you are sure that the keyboard is displayed and you can even manually hide the keyboard, a forced way to do that is as #Gaurav has suggested in the comments using the following code :
driver.navigate().back();
In case of uncertainty of the visibility of keyboard, you can give this a try :
driver.getKeyboard();
driver.hideKeyboard();
Related
I have freshly added a bunch of key commands (Cmd-..., etc) in the app by implementing
-(NSArray<UIKeyCommand*>*)keyCommands;
on a UIViewController subclass. Everything works wonderfully when manually tested in the app. The problem is how to UI test this in the iOS simulator.
I don't seem to be able invoke these commands using a method on XCUIElement. According to its documentation, there only seems to be one text input method on iOS
- (void)typeText:(NSString *)text;
with no (apparent) way to bless the input character with a key modifier flag (XCUIKeyModifierFlags) for Cmd, Alt, etc keys.
The method
- (void)typeKey:(NSString *)key modifierFlags:(XCUIKeyModifierFlags)flags;
appears to be macOS only. It would be a shame to provide these commands but not be able to test them in our UI testing suite.
Any ideas that can help me make some progress would be hugely welcome.
The keyboard input of the iphone emulator requires some settings. Make sure you currently select the simulator, and then set it in the upper left corner toolbar:
I/O -> Input -> Send Keyboard Input to Device
I/O -> Keyboard -> Connect Hardware Keyboard
So I'm testing a web app for which I have to open a new tab, switch to it, do some input, than switch back to the first tab and this more than once.
I try to open the new tab this way:
((JavascriptExecutor) AppiumTestBase.getDriver()).executeScript("window.open('http://google.com', '_blank')");
This causes the following alert to appear:
But I'm not able to accept it through automation with Appium. Things that I have tried:
Using the following capabilities: "safariAllowPopups" and "autoAcceptAlerts"
Changing the according settings for safari in the iOS sim
.switchTo().alert().accept(); I also waited for the Popup.
Switchting to native context before accepting the popup
Clicking the pop up by name .findElement(By.name("Allow")).click();
What I have not tried:
Taping on the screen according to the pop-up coordinates. I didn't try this since I'm not sure on how to get the position of the "Allow" button.
And my other question is how would I switch between two tabs? I haven't tried anything yet, but research would suggest that I try it with window contexts.
Some other information:
Currently testing with a iPhoneSE iOS 9.3 Simulator, the solution should work for several configurations
Appium is on the most recent version
The class "AppiumTestBase"s only purpose is to set capabilities and initialize the AppiumDriver
Please try this cap after i change to this no popup from safari anymore
desired_capabilities=automationName:XCUITest,browserName:safari,platformName:iOS,platformVersion:11.1,deviceName:iPhone 6,nativeWebTap:True,safariIngoreFraudWarning:True
I tried the solution suggested by Atthaboon Sanurt, but it didn't help.
There was no alert, but the new window/tab didn't open either.
Here where the problem is reported:
https://github.com/appium/appium/issues/6864
So far it looks like there is no solution and plans to fix it.
I have devoleped a simple iOS app and on test using Appium all the UIControls staus is shown as visibility false. The below image is the screenshot of the test. I set accessibility label on storyboard
The code I wrote for a simple textfield is given below.
self.txt_txt.isAccessibilityElement = YES;
self.txt_txt.accessibilityElementsHidden=NO;
I have done a little R&D on this and haven't found anything keep 'visibility ' true for UIControls.How to keep visibility true in the above case.If not in code are there any other scripts to run?. Any thoughts are welcome.
I believe this is a bug when using iOS8, based on the information shown in the Appium bug database here:
https://github.com/appium/appium/issues/4131
Looking at the last comment to this bug, it seems that in iOS7 elements are correctly identified as "visible: true", but the same ones in iOS8 are not.
As far as I understand it, at the moment it's not yet clear if this is a bug in Appium or in iOS8.
In the past i have done subclassing of UITableView and UICollectonView many times, in which i have assigned self to the delegate and datasource, and it worked fine.
Today i tried to make subclass of UITextField and in that I am assigning self to its delegate as
self.delegate = self
where delegate is inherited from UITextFiled.
In above case this is hanging the App forever in iOS 7, but works for iOS 8.
Another surprising thing is, when i try to input the text in it from Hardware keyboard then it works fine but it get hanged on typing characters from On-Screen keyboard.
What may be reason of this, Can any one help me to understand?
I was having a similar issue and I figured it out. The simulator will not raise the keyboard by default anymore. If there is a hardware keyboard available and detectable (for example on a MacBook) the simulator will look for input from it and the simulated iPhone keyboard will not raise. This gives the appearance of a problem with the delegate. All you have to do is in the Simulator's Hardware menu, under Keyboard, unselect the option for "Connect Hardware Keyboard". I hope this helps.
We are using a BT device, which acts as a keyboard, to talk to the iPad.
We want this bluetooth device to talk to 1 field in our app. (Which is on it's own view)
All other textFields/areaFields we want to display the virtual keyboard.
Is this possible?
Whenever the BT device is paired it disabled the on screen keyboard.
We thought of turning bluetooth off before the view with the 1 field that needs its input from the device is displayed and then turning it back on when the view is removed, but this has 2 problems. The iPad will not automatically connect to the device and there is no way to turn bluetooth off without using private API's.
This is a related question:
Force on screen keyboard to show when bluetooth keyboard connected
that has not yet got a satisfactory answer.
Any help will be greatly appreciated
Cheers
Phil
Erica Sadun found a way of bringing back the keyboard by sending a GraphicsServices event. Post: http://www.tuaw.com/2010/06/02/hacksugar-bringing-back-the-on-screen-keyboard/ see link to source code. Sending GSEvents might not be AppStore ready, but maybe worth a try.
Phil,
I'm not sure if you've discovered the External Accessory Framework but that is probably your best bet to get what you're after and have an app that will be accepted in the store. I'm currently working through some similar issues and I think this is how I'll be able to detect which of our supported devices the user is using.
https://developer.apple.com/library/ios/#documentation/ExternalAccessory/Reference/ExternalAccessoryFrameworkReference/_index.html
EAAccessoryManager looks like it may give you back a list of attached devices. That's exactly what I'm looking for. It should allow me to then take the correct path to connect to the devices.
This may give you back what you're interested in...
#import <ExternalAccessory/ExternalAccessory.h>
- (void)_getAttachedDevices;
{
EAAccessoryManager* accessoryManager = [EAAccessoryManager sharedAccessoryManager];
if (accessoryManager)
{
NSArray* connectedAccessories = [accessoryManager connectedAccessories];
NSLog(#"ConnectedAccessories = %#", connectedAccessories);
}
}
Hope this helps.