Uiautomator - cannot use UiObject2 - android-uiautomator

I'm trying to create a new UiObject2 in UiAutomator but I receive the following message:
UiObject2(android.support.test.uiautomator.UiDevice, android.support.test.uiautomator.BySelector, android.view.accessibility.AccessibilityNodeInfo) is not public in 'android.support.test.uiautomator.UiObject2'. Cannot be accessed from outside package
Does anyone know how to fix this?

UiObject2 resultsObj = mDevice.findObject(By.clazz("android.widget.ExpandableListView").res("android:id/list").pkg(PACKAGE_NAME).scrollable(true));
Did you add androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' in projectRoot-app module-build.gralde?
And write your test code under app module-androidTest?

Related

SonarQube plugin: how to get property value from command line -D

I am new to sonar plugin development. I wrote a plugin and add PropertyDefine to context. And then I wanna get my property value passed by
gradle sonarqube -Dmy.proper.name=xxx
I don't know what are the next steps? Plz help.
Thanks.
All -D parameters can be get by using java.lang.System class:
String valueOrNull = System.getProperty("my.proper.name");
or
String valueOrDefault = System.getProperty("my.proper.name", "defaultValue");
Hi #agabrys thanks for your answer. But I found out that if you wanna get the property from Scanner side, you need make a PostJob like class to deal with it. I didn't clearly know that so I didn't know why I couldn't get that property. Thanks anyway.

Espresso Perform Exception happening in CI only

I am using Bitrise to run some Android espresso UI tests, but I cant seem to find a solution for this Perform Exception:
android.support.test.espresso.PerformException: Error performing 'single click' on view 'with id: com.selfcarecatalyst.healthstorylines.adda:id/male'.
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)
Im testing a sign up page that has a few fields. If i skip clicking one field, I get the same error on the next click on this form. The relevant code is:
public void clickMale_onInfoPage(){
onView(withId(R.id.male)).perform(click());
}
public void setFirstName_onInfoPage(String name){
onView(withId(R.id.first_name)).perform(typeText(name));
closeSoftKeyboard();
}
setName is called first, and i added a softclosekeyboard thinking this would solve it but it did not :(
This is running through a CI, and sorry but Im a little new and not sure how to get a better error message/stacktrace. Any help would be much appreciated!
You should also try to call closeSoftKeyboard() before performing the click action.

Invoke Method with client.soda ( Statement Object Model )

I am trying to build Esper EPL statements in Java.
I use the com.espertech.esper.client.soda lib for this, but I can't find
a tutorial to help me.
The PatternExpressions are the only part that I need as of now.
As an example let's use the EPL:
every a=Event((a).getEventTypeCode()='E00001')
So he should trigger on every Event with the event type code E00001, we get the code by
calling the getEventTypeCode Method.
How do I project this to SOM?
With:
PatternExpr pattern = Patterns.everyFilter("Event","a");
I only get:
every a=Event
(of course)
I know there is a class called "MethodInvocationStream" but I don't know how to use it.
And I cannot find examples for its use.
Thanks to user650839 I found out how to add Methods via SOM.
Here is a simple EPL as an SOM Object: http://imgur.com/SDrTsa7
One source of info is the javadoc.
You could simply do the reverse and compile EPL text to a model object and inspect that. Use "epAdmin.compileEPL", the output is the same object you want to build via API.\

Xtext get the absolute path of the generated files

I want to access the file generated by Xtext to compile it automatically. So I need its absolute path. It's enough to get the absolute path of the current project at run-time. Any idea how I can get it?
I am working inside the "MyDslGenerator" Class. I tried to get it from the "resource" in
override void doGenerate(Resource resource, IFileSystemAccess fsa)
but couldn't find it.
Help is highly appreciated.
I ended up using this code:
var uri = (fsa as IFileSystemAccessExtension2).getURI(fileName)
maybe you can use the Interface org.eclipse.xtext.generator.IFileSystemAccessExtension2. the passed IFileSystemAccess may implement this interface too.

Cache won't work in Appcelerator

Titanium SDK version: 1.6.
iPhone SDK version: 4.2
I am trying out the cache snippet found on the Appcelerator forum but I get an error: [ERROR] Script Error = Can't find variable: utils at cache.js (line 9).
I put this one (http://pastie.org/1541768) in a file called cache.js and implemented the code from this one (http://pastie.org/pastes/1541787) in the calling script, but I get the error.
What is wrong? I copied the code exactly.
Your problems is whilst the first pastie defines utils.httpcache. The variable utils is not defined outside of this function closure (because it is not defined anywhere in global namespace). As below shows.
(function() {
utils.httpcache = {
};
})();
To make it all work in this instance add the following code to the top of your cache.js file.
var utils = {};
This declares the utils variable in global namespace. Then when the function closure is executed below it will add utils.httpcache to the utils object.
The problem is actually not specific to Appcelerator and is just a simple JavaScript bug. Checkout Douglas Crockfords book, JavaScript the Good Parts. Reading it will literally make you a more awesome JavaScript developer.
You can't use utils.httpcache.getFromCache(url) until you add this to your code:
var utils = {};
That's because how the author created his function, it's called JavaScript module pattern and it's generally used to structure the code.
I seem to lose this value "value.httpCacheExpire = expireTime;" when the code does the "Titanium.App.Properties.setString(key,JSON.stringify(value));" so when I get it back using the getString method, there's no longer the "value.httpCacheExpire.
Anyone else have this issue? Am I missing something to get this working?

Resources