How to click/tap on content drawn using core graphics in appium for iOS - ios

I am new to Appium and use it for iOS native app automation.
Appium version : 1.2.0
Webdriver : Selenium
Testing framework : JUnit
Programming language : Java
I have an iOS application where the contents are drawn using Core Graphics. I need to click/tap on certain content(word) using Appium with the co-ordinates specified.
My question is, how can I tap on the content drawn using CG?
For example, how can I click on "Start" using Appium using co-ordinates where the origin is x=0, y=102 and size is height=305, width=320.
The content is present within this and must be scrolled for other contents.
I tried with .tap, .press of TouchAction(). The test case passed but it has not clicked.
Please help me solve this.
Thanks in advance.

This is the general gist of what you need to do to tap something. (My attempt at a Java translation of my python code)
WebElement application = driver.findElement(By.xpath("//UIAApplication[1]"))
Action action = TouchAction(driver)
action.tap(application, x, y, 1).perform()
When testing drawing/tapping code, I like to point it at a sample drawing app like this one and that lets me see exactly what's going on.

Related

How to use Appium to select the elements from a searchview dropdownlist?

As you can see in this picture, I can't locate the Id or XPath of the details I want to click. I'm using AndroidDriver.
I had tried the following codes:
AndroidElement searchView = androidDriver.FindElementByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(text(\"Tribology Testing\"));");
but I still can't get the Tribology Testing being select.
We cannot help you to come up with the correct element locator without seeing your application layout, screenshot doesn't help at all.
You can see the layout by invoking AndroidDriver.getPageSource() function - it will print all the UI hierarchy of the current screen and you will be able to create the corresponding selector.
Another options are:
Android Device Monitor (part of Android SDK)
Layout Inspector (part of Android Studio)
XPath Feature of the Appium Studio

Get all elements in the view of iphone app using xcode

I am trying to take screenshot of every screen during iphone app automation on a simulator. Along with the screenshot I also want to extract all strings in the that particular view before taking a screenshot using xcode. Is there a way to do that? Purpose is to send these screenshots and strings for validation to another tool.
This can be done using Web Driver Agent(WDA) provided by facebook. It does provide all the functionalities you need for your app.
Here is link to github repo for it:
https://github.com/facebook/WebDriverAgent
Please have a look at it. It might help you achieving your goal.
If you are using the XCUITest framework for your automation, you can use XCUIScreen.main.screenshot() to get a screenshot of the current state.
To fetch all text currently on screen you can use XCUIApplication().descendants(matching: .textField) or .buttons or .any or whatever you expect to be on the screen, and extract the text from the element
let descendants = XCUIApplication().descendants(matching: .textField)
foreach descendant in descendants { descendant.label /*do something*/ }
You need to set an Accessibility Identifier on the view elements for this to work.

Appium::TouchAction.new.tap doesn't work correctly

And(/^I click OK button in popup$/) do
#Appium::TouchAction.new.tap(x:0.64, y:0.57, count: 1).perform
Appium::TouchAction.new.tap(x: 270, y: 506,count: 1).perform
end
And(/^I click Allow button in popup$/) do
#Appium::TouchAction.new.tap(x:0.64, y:0.57, count: 1).perform
Appium::TouchAction.new.tap(x: 270, y: 506,count: 1).perform
end
Given the next code, I work with Appium 1.9.1, Ruby 2.3.7 and Cucumber to automate iOS app, if I'm passing relative coordinates (percentage) - then appium doesn't perform any taps, but, if I comment out lines with absolute coordinates and comment lines with relative coordinates - all taps will work. The strangest thing is that if I use relative coordinates in 1st line and absolute coordinates in second line - it will perform first tap, but won't perform second.
My goal is to use relative coordinates everywhere, so tests will be usable on devices with any screen resolution, please advice, if there are any known solutions to use relative coordinates (or if I'm doing smth wrong)
After going through your code snippet, I assume you are dealing with alert pop-up in iOS device.
In iOS, with Appium Java client, I can deal with pop-up using traditional driver.switchTo().alert();.
Here driver refers to IOSDriver.
I'm sure there must be equivalent to this in Ruby as well.
Try using Alert class to accept the alerts instead of tapping on the coordinates.

Swipe with Appium using Java is not possible in ios apps

When I'm trying for swipe operation in ios apps it is showing this error.
[org.openqa.selenium.UnsupportedCommandException: Unknown command, all
the mobile commands except scroll have been removed. (WARNING: The
server did not provide any stacktrace information).]
please give me the solution.
From the sounds of the error the method you are using is not implemented in appium. How are you calling it?
I am able to swipe in my iPhone (9.3.5) using xcode 8 (XCUI driver type) using the command:
driver.swipe(startx, starty, endx, endy, duration
Where the above 4 arguments are positions on the screen, and duration is the length of the swipe (make sure to use a short one as a duration that is too long will cause the iOS magnifying glass to appear)
If that doesn't work you should specify the following information:
Appium Build:
XCode Build (If applicable):
Device and OS:

Implement Camera in Custom page in Cordova iOS

In Cordova and Meteor.js, is it possible to implement the Camera function into our own custom page, getting it to look similar to the following in iOS:
I don't know about Meteor.js but I can tell you about cordova-plugins.
Yes you can do it by using mbppower/CordovaCameraPreview plugin that allows camera interaction from HTML code. To create your custom camera what you should do is, start camera on your HTML page. You have to draw rectangle for "Camera Preview Box" with required height-width dimensions and starting point(x,y) as parameters in below code snippet.You can also make it Tap enabled and Drag-able.
cordova.plugins.camerapreview.startCamera({x: 100, y: 100, width: 200, height:200}, "front", tapEnabled, dragEnabled, toBack);
Now its on your HTML page only, so you can add Capture button, Browse picture button, Flash or anything you want. It will be like your custom camera only. A big thanks to its author, he has done a great job..
Added more stuff:
you can also use donaldp24/CanvasCameraPlugin Plugin for your application, its supported in both android and iOS. For iOS its working, but in android isn't working properly for me.
UPDATE:10th Oct 2017 It used to work well during that time but, donaldp24/CanvasCamera is no longer maintained and currently fails build with the latest Cordova version.

Resources