Appium driver to get app package name programmatically - java

I am using:
appiumDriver.findElement(By.id("com.XXX.keyword:id/nextButton"));
but sometimes we have debug version, so we have something like "com.XXX.keyword.debug". So I want to get package name before test runs so the tests can be independent on this.
I tried
driver.currentActivity()
but it only returned something like ".MainActivity"
Is there any way to get package name with Appium?
Thanks a lot.

You don't need package name to locate elements. Simply copy paste id without package name . eg in your case use only 'nextButton' instead of 'com.XXX.keyword:id/nextButton'

To get the current package name use following method:
driver.getCurrentPackage();
The following statement you are using will give you Activity Name.
driver.currentActivity();

Related

Why this particular code generates "ambiguous method call" error in Android Studio?

I use iText 5 in Android Studio to create a PDF document but I get an error:
I also tried
p.add((Phrase)c);
but I get same error :-(
How I can get rid of this error?
"ambiguous" error comes up when u already have a file/varibale etc with same name.
for example when you make a project using entity framework , entity framework make class and dbcontext files for u. but if u add a class with same name as entity framework had made for u then this error comes up. check ur project/programe correctly and fully again...
Hope its helpfull !!
and checkout this link for ur answer Android Studio - Ambiguous method call getClass()
thanks for reply - indeed I needed help regarding why 'ambiguous' appears in this context.
But now the problem is solved - this error does not appear anymore - but I don't know exactly why.
I did some Android Studio updates last week may this helped?
Thanks anyway!
In case when we use data binding, some java files are auto-generated
The problem was occured when a getter/setter has the same name with a function.
eg
var newData
fun getNewData()
in this case, in the generated java file, the variable's getter has the same name with the function => getNewData.
So simply you have to change variable name or fuction name

Get Test Instance Names from test set folder in Java using API

I am trying to get the test instance names from the test set. I am able to get the test id by using the following URL:
"rest/domains/"+domain+"/projects/"+project+"/test-instances?query={cycle-id["+testSetId+"]}" ;
Is there any way I can get the test names also?
I guess you're talking about the ALM Rest API.
If you do, you can try to add in final of your URL the following:
&fields=test-config.name
Then your URL will look like this:
rest/domains/{domain}/projects/{project}/test-instances?query={cycle-id[{testSetId}]}&fields=test-config.name
The name of your Test Instance will be shown into the RelatedEntities tag from your XML.
For more information about ALM REST API you can click here.

GetActiveNotifications () method how use it to find a package?

I know i can use this method: GetActiveNotifications() to get the active notifications in my notifications bar but i don't know why.. What i want exactly is check if a package name is present or not so then i can make a condition to read the notifications of specify app. I can get the package name in this way:
Log.i(TAG,"Package Name" + sbn.getPackageName());
but the problem is create the right method with all informations. Can anyone help me? Thanks

Java error: Context already contains a binding with name ""

Ok so I have followed this tutorial step by step: Custom Java Desktop Database Application
I can't understand what I'm doing wrong but when I run the application and click on "New Customer" i get the following error:
Caused by: java.lang.IllegalArgumentException: Context already contains a binding with name ""
I believe that it has something to do with the combobox which is binded with the countries list which comes from the database. The binding expression is set to null and binding source is set to countriesList.
Any help would be appreciated guys?
Thanks
SOLVED
When binding elements of the combo box, in the advanced tab, I just set the name to "null"..and it started working.
while giving "null" into Identification's name works, it only works for the second occurance, you may not repeat the "null" string as the name for the third or any other occurances.
Because,
actually the only one we need to remember is, the name needs to be unique. That's all :)
It seems something was changed in Netbeans. The bindings don't need a name, but for some reason Netbeans started adding "" as the name of many bindings. My solution has been to open the .java file in another editor and just removing the last , "" in the createAutoBinding method call.

In AppEngine for Java, how do you get the name of the instance: e.g. instance.appspot.com

I want to get what the name of my instance is from within the app.
THANKS
It looks like you can use SystemProperty.applicationId.get(), see here:
http://code.google.com/appengine/docs/java/runtime.html#The_Environment
http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/utils/SystemProperty.html

Categories

Resources