Reputation: 1825
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.
Upvotes: 5
Views: 5215
Reputation: 798
To get the current package name use following method:
driver.getCurrentPackage();
The following statement you are using will give you Activity Name.
driver.currentActivity();
Upvotes: 2
Reputation: 1790
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
'
Upvotes: 3