I am using appium (v1.10.0) for automating iOS native app on macOS(10.13.6) using Xcode 10.1 on a real device (iPhone 6s) of platform version 12.1.3. When I start appium server and start session, the app will open in the device. Once I run the code in eclipse to send the Username to login page of the app, mobile keyboard is not getting opened and hence sendkeys() is not working.
Tried getKeyboard() before sendkeys(). Still the error exists. Below is the code which I tried.
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("device", "iPhone");
cap.setCapability("deviceName", "iPhone 6s");
cap.setCapability("platformVersion", "12.1.3");
cap.setCapability("platformName", "iOS");
cap.setCapability("app","/Users/TP/Desktop/SampleApp.ipa" );
cap.setCapability("udid", "xxxxxxxxxxxxxxxxxxx");
cap.setCapability("automationName", "XCUITest");
cap.setCapability("xcodeOrgId", "xxxxxxxx");
cap.setCapability("xcodeSigningId", "xxxxxxxx");
driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
driver.findElement(By.xpath("//XCUIElementTypeApplication[#name=\"TBI\"]")).click();
driver.getKeyboard().sendKeys("abc");
Mobile keyboard is not getting opened and hence throwing the following error.
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command.
Original error: Error Domain=com.facebook.WebDriverAgent Code=1 "Only actions of 'pointer' type are supported. 'key' is given instead for action with id 'keyboard'" UserInfo={NSLocalizedDescription=Only actions of 'pointer' type are supported. 'key' is given instead for action with id 'keyboard'}
you don't need to use getKeyboard() you can directly send the value to the fields
Send Keys sends a sequence of key strokes to an element.
Can you replace the following two lines
driver.findElement(By.xpath("//XCUIElementTypeApplication[#name=\"TBI\"]")).click();
driver.getKeyboard().sendKeys("abc");
with
MobileElement mobileElement = driver.findElement(By.xpath("//XCUIElementTypeApplication[#name=\"TBI\"]"));
mobileElement.sendKeys("abc");
Try this. Worked for me:
IWebElement currentElement = driver.SwitchTo().ActiveElement();
currentElement.SendKeys("any text");
Related
I am doing some automation with Appium on a iOS mobile app.
I need to:
open the app
do some tasks
open safari
I looked around how to do it but I've been reading that it's impossible due to a limitation in apple's framework, it doesn't allow you to sent commands to more than one app per session.
Does anyone know a way around this? Or if what I read is just not 100% true.
it doesn't allow you to sent commands to more than one app per session
Thats true, but you can run 2 sessions in a single test:
create instance of appium driver with app-based capabilities
do what you need in the app
quit driver
create instance of appium driver with browser-based capabilities
do what you need in the safari
quit driver
In a quick way it may look like:
#Test
public void testBothAppAndSafari() throws MalformedURLException {
URL appiumServerUrl = new URL("<your appium server host>");
DesiredCapabilities appCaps = new DesiredCapabilities();
// put required native app capabilities in appCaps
DesiredCapabilities safariCaps = new DesiredCapabilities();
// put required safari capabilities in safariCaps
IOSDriver driver = new IOSDriver(appiumServerUrl, appCaps);
driver.findElement(<locator for element in native app>).click();
// do whatever you want with mobile app
driver.quit();
driver = new IOSDriver(appiumServerUrl, safariCaps);
driver.findElement(<locator for element in web>).click();
// do whatever you want in safari
driver.quit();
}
You can use following approach,
Created two setup one for app and other for safari.
First launch application and perform task
clear first session
Created again new Appium object for safari ( call second setup )
Perform browser activity
Close safari appium session
You also can follow my approach without quit driver.
Go terminate application. (I've used javascript to run terminateApp cause native method not work for me.)
Find Safari on Home screen and then click on it
Use drive.get to open website as you expected.
In there you can change to WEBVIEW_*** to inspect web element.
Back to native context by NATIVE_APP keyword
Sample code:
System.out.println("Run application");
Map<String, Object> params = new HashMap<>();
params.put("bundleId", "com.example");
boolean terminalApp = (boolean) driver.executeScript("mobile: terminateApp", params);
System.out.println("terminateApp: " + terminateApp);
driver.findElementById("Safari").click();
Set<String> contextNames = appDriver.getContextHandles();
// Change context to WEBVIEW_***
appDriver.context(String.valueOf(contextNames.toArray()[1]));
driver.get("https://www.google.com.vn");
Thread.sleep(20000);
// Do something.
// ...
// If you want to communicate with NATIVE context just change to NATIVE_APP.
appDriver.context("NATIVE_APP");
you can activate system apps via driver.activateApp(BUNDLE_ID);
there is no need to kill the app driver and start browser driver to access browser, just switch between apps.
safari
driver.activateApp("com.apple.mobilesafari");
Here is how I resolved the issue:
driver2.activateApp("com.apple.mobilesafari");
Thread.sleep(5000);
boolean openSafariTab =
driver2.findElements(By.xpath("//XCUIElementTypeButton[#name=\"AddTabButton\"]")).size() > 0;
if (openSafariTab) {
driver2.findElement(By.xpath("//XCUIElementTypeButton[#name=\"AddTabButton\"]")).click();
} else { }
Thread.sleep(3000);
driver2.findElement(By.xpath("//XCUIElementTypeTextField[#name=\"TabBarItemTitle\"]")).click();
Thread.sleep(3000);
driver2.findElement(By.xpath("//XCUIElementTypeOther[#name=\"CapsuleViewController" +
"\"]/XCUIElementTypeOther[3]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]")).sendKeys("https://www.golfbpm.com");
Thread.sleep(3000);
driver2.findElement(By.xpath("//XCUIElementTypeButton[#name=\"Go\"]")).click();
I am new to Appium. I did set the configurations and tried to test samsung galaxy tab of android kitkat 4.4.2. The device is not getting identified by the appium. The device is getting identified by the android but not appium.Please do help me to resolve the issue.
I am giving the coding here
#BeforeTest
public void setUp() throws Exception {
/*
* File classpathRoot = new File(System.getProperty("user.dir")); File
* appDir = new File(classpathRoot, "../../../apps/ApiDemos/bin"); File
* app = new File(appDir, "ApiDemos-debug.apk");
*/
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("automationName","Selendroid");
capabilities.setCapability(CapabilityType.VERSION, "4.4.2");
capabilities.setCapability("deviceName", "4d0001f745b350e1");
capabilities.setCapability("platformName","Android");
capabilities.setCapability(CapabilityType.BROWSER_NAME,"chrome");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities);
}
#AfterTest
public void tearDown(){
driver.quit();
}
#Test
public void apiDemo() {
driver.get("http://www.facebook.com");
}
and when I am running this,Appium is showing as 0 connected devices.
But the same configured Appium is working fine with emulator of 4.3.
check your cable connection
Are you able to see your device on adb devices directly ?
if your not able see on adb devices , den please enable usb debugging and tap on yes on the prompt that will authorize your device.
check drivers for your device and install
check connecting with debugging other in other mode instead of mtp mode
I'm using the org.apache.cordova.device plugin. I see that device.name has been deprecated a while back in favor of device.model. When using device plugin 0.2.12 and iOS 8.1 on iPhone 5S, device.name is undefined.
I still need to get the user's device name, like "Jerry's iPhone", so that the user can see which of their devices are using my app. How to do that with Cordova?
Your best bet might be modifying the Device plugin (with all the undesired consequences). I was able to get the device name by adding the following line to deviceProperties in ./cordova/platforms/ios/[project name]/Plugins/org.apache.cordova.device/CDVDevice.m:
- (NSDictionary*)deviceProperties
{
UIDevice* device = [UIDevice currentDevice];
NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4];
[devProps setObject:[device name] forKey:#"name"]; // <------------- new line
You also need to adjust the corresponding Javascript object in ./cordova/plugins/org.apache.cordova.device/www/device.js:
channel.onCordovaReady.subscribe(function() {
me.getInfo(function(info) {
me.name = info.name; // <---------- new line
device.name may have been deprecated and removed from the plugin, but the assigned name is still a supported attribute as of the iOS SDK 8.1 documentation.
The device plugin does not support the name, however there is another plugin that does:
https://github.com/becvert/cordova-plugin-device-name
I started in blackberry development.
Currently, I try to develop App with:
Blackberry Widget API (Javascript + CSS) and Eclipse (JAVA)
1/
When I try with Blackberry Widget API, I try to load a webservice in .NET, I try to run this in simulator 8520 curve... and the connect to the webservice not works, I use the config.xml to set the domains but nothing happends, later I test in 9800 simulator and works fine... but I have some fear because this app is for run in any device :(
2/
When I try with Eclipse and kSOAP2 Library,
This is my code:
String WSD_URL = "http://service.com/service.asmx";
String WSD_NAMESPACE = "http://service.com/GetInfo";
String WSD_ACTION = "http://service.com/GetInfo/fGetInfo";
SoapObject soap = new SoapObject(WSD_NAMESPACE, "fGetInfo");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.bodyOut = soap;
envelope.encodingStyle = SoapEnvelope.XSD;
HttpTransport ht = new HttpTransport(WSD_URL);
try {
ht.call(WSD_ACTION, envelope);
} catch (Exception e){
}
When I launch the app in simulator... nothing happend, few minutos after I see a error in the white screen with message "controlled access exception" :(
I have doubt here because I dont know how to solve this and if this app run in any devive.
In eclipse I see JRE 6.0
To access dot net webservice, instead of Ksoap method, try this one.. http://whatpaulhaslearnt.wordpress.com/2011/04/19/consuming-a-net-web-service-from-a-blackberry-native-application-using-the-java-me-platform-sdk-3/ .. this is the best way of accessing dot net webservice..
i didnt get the output of the code.
HttpConnection httpConn;
httpConn = (HttpConnection)Connector.open("http://mydomainname.getsample.php?getData=mydata");
httpConn.setRequestMethod(HttpConnection.GET);
int iResponseCode = httpConn.getResponseCode();
System.out.print(iResponseCode);
what is the error?. how i get the output ?
iam using blackberry simulator. on pc, the url retriving the data.
if you are using eclipse
right click on the project->run as ->run configurations->simulator
check the option for launch mds with simulator.