Implement Camera in Custom page in Cordova iOS - 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.

Related

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.

How to click/tap on content drawn using core graphics in appium for 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.

Is there/what is a UIImagePicker allowsEditing equivalent for Windows Phone SDK?

At the moment, I am in the process of trying to convert my iOS app over to Windows Phone 8, however, in my iOS app, I used the UIImagePicker's allowsEditing method to get what happens in the image below.
In the image below, the user can resize the picture they have selected so they can use only the part of the picture they selected in the app, while also the picture they select gets cropped into a square for the app to easily use too.
My question is, now that I am making the app using the Windows Phone 8 SDK, is there a simple method to get this same functionality, or will I have to program this functionality in myself?
Thank you very much.
Jon.
You should use the PhotoChooserTask with the PixelHeight and PixelWidth properties:
photoChooser.PixelHeight = 612;
photoChooser.PixelWidth = 612;

Zbar not working after changing setSymbology

I want Zbar to capture images as well as scan QR code with the single Zbar reader without dismissing it from the current ViewController.
For that I was using
[reader.scanner setSymbology:ZBAR_QRCODE config: ZBAR_CFG_ENABLE to:1];
to enable when the slider changes to the QR code mode and
[reader.scanner setSymbology:ZBAR_QRCODE config: ZBAR_CFG_ENABLE to:0];
to disable the QR code mode when the slider is set to certain value.
It is not working properly by changing like that. If the QR code is enabled initially, the zbar reader scans well the QR code.
But I wanna show just an image picker initially, so I put on the above code that disables the QR code mode and would change the symbology as needed. By changing the symbology, the QR code is not working. Can someone please help me fixing this showing me what went wrong?
Im working on the latest release with iOS 6.0. Thanks in advance.
You would have probably solved the problem by now. The problem is hard to imagine though but one of either solution will solve it:
Use ZBarReaderController instead of the ZBar ReaderViewController so you have control when the barcode gets captured. (The symbology support is set once before you initialise
the controller I do not believe you can change symbology support dynamically, also since you only disabled QR Codes - it will continue to support the other 20 or so barcode formats.
If you want to pick images from the camera roll you need to do it outside the Z bar reader controller but you should still be able to decode the resulting image using Z-Bar - it should be easy to figure out in the sample app.

Resources