Can Appium automate mobile apps build on Titanium Appcelerator? - titanium

I'm trying to automate the App build using Titanium Appcelerator.
When I'm inspecting elements using UIAutomator I'm not able to find the resource-id. I'm using path as a workaround but this is not a long term solution.
Has anyone worked with Appcelerator and Appium and is able to help me out?

It is definitely possible to use Appium with Appcelerator Titanium! The key is using the accessibilityLabel property on your views.
i.e. <Label id="label1" accessibilityLabel="label1" text="I am label1" />
You can then do something like this in your Appium tests:
it('should have label1', function() {
return driver
.elementByAccessibilityId('label1')
.should.eventually.exist
.getAttribute('value')
.should.become('I am label1');
});
Let me know if you have any questions about it! I will probably together a blog post about it here because I know a lot of other devs have the same questions you have.

Related

Nativescript localization testing using Appium - text extraction

I'm currently trying to figure out a good way to test localization of an app and have some trouble accessing the label text of a button UIElement after i've accessed the element by automation text. After accessing the button UIElement i'm only able to get the automationText to test against.
It's my first time doing any form of testing with nativescript, appium and mocha and i might go about it completely wrong and if so advise would be much appreciated.
What i'm testing on
- iPad simulator (9.7 inch) with OS v. 12.4
- node v10.16.3
- npm v6.9.0
- {N} v. 6.0.1
- runtimes v 6.0.1
- nativescript-localize for i18n localization
I've followed setup instructions and found some issues here where people hadn't installed carthage, which i've installed.
A simple test looks something like this
const daDK = require(dk.default.json); // localization file for danish
const changeUserButton = await driver.findElementByAutomationText('changeUserButton');
expect(await changeUserButton.text()).to.be.equal(daDK.user.change_user);
The problem:
Doing a log of the await changeUserButton.text() retreives the automationText = changeUserButton where it should have been the text property with the value: Skift Bruger.
I've also tried to access elements in different way ie. with findElementByXPath and findElementByText (though i've read text is only android).
Any suggestions as to solve this?
I've also made an issue with even more details on nativescript-dev-appium Git repo here
Thanks in advance!

ListView section headers don't seem to be working on Android, but they work fine on iOS?

Has anyone had success with ListView section headers on Android? Using the documentation and a few handy tutorials I was able to build this for iOS:
When we run the code on Android (Lollipop and Marshmallow) the ListView just acts like a ScrollView...no section headers :(
Has anyone else run into issues with the ListView on Android? Were you able solve them? We're no against building a separate component for Android so if you know of another react-native component that can be used to achieve this effect that would be great too.

adapting javascript to titanium

in my app I have to compare two images, so I found this code.
I tried on my localhost and work fine but I have to do the same on appcelerator and I have some errors, the first is on var img = document.createElement('img');, then on getContext.
is there a way to adapt the code to titanium?
First of all, Titanium is not HTML so you cannot use DOM things as that code does. Though you can use Javascript but Titanium has its own sets of API and it is really superb and broad. Look here to know what you have got under the hood in Titanium
You have to look into many APIs to make your task done, but first you need to understand what that code is trying to do and what you want to achieve because if you understand the logic, then you can do it in Titanium as well. But please do not adapt DOM or HTML to Titanium :)

How can we achieve coverflow view in android titanium?

I have seen that titanium support CoverFlowView in titanium but it works only on ios, Can anyone have idea to achieve CoverFlow in android with titanium
Thanks in advance
Looks like you are in luck! Someone already built a coverflow module for Android using the Android development environment.
https://github.com/moondroid/CoverFlow
You need to be willing to write the additional code for that to turn it into a module for Titanium.
http://docs.appcelerator.com/titanium/3.0/#!/guide/Android_Module_Development_Guide
It should be possible, but I must admit I've never tried to write one myself.
Basically you cannot get Coverflow on Android. Since it is a native iOs component which is not implemented in Android at all. Frameworks like Titanium always "link" your commands to internal system APIs. When there is no API there is no way to access it. Of course you could try to build it on your own but I think this would not work that well. And its a lot of work!
Additionally cover flow is not really useful (except for holding just a few items). Have a look at my question at ux.stackexchange.

Verifying toasts using Appium , and get server reaction to button clicks

i'm new to android automation testing and i recently started to work with Appium.
I use it for android native app automation.
I have 2 question -
is there a way to verify toasts?
the latest posts i saw which referred to this issue are from the mid of 2014
and i wanted to know if there's something new in this subject before i will find another tool to run my tests with (as i understand selendroid can verify toasts).
is there a way to catch the http request which my app sends to the server when i'm pressing a button, during the automatic test?
something like a listener which works in the backround and wait for clicks?
tnx
To verify toast messages you can use one of image recognition libraries. For ruby I use RTesseract together with image processor RMgick
Idea is simple:
make toast message to appear
take few screenshots
iterate over taken screenshots and look for text
You may play with image processing, to increase recognition quality.
Here you can find code snippet which I use in my framework: link