Appium IOS Native app find element by label - java

Can we find an ios native application button by it's label using appium ?
Using Accessiblity Inspector, only labels can be found.
We do not have the source of the app that we seek automate, it's already installed.
Thanks !

You can consider the following alternatives to the accessibility inspector:
Appium iOS Inspector
Appium Desktop
Appium Studio
Also be aware that you can always stick to the label attribute by using XPath Selector like:
//*[#label='your label text here']

Unstead of IOSDriver ,we were using RemoteWebDriver, wich lacks many features.
Now, we're using Accessibility ID.

Related

how to send some String value to ios real device clipboard using appium?

I've searched over the topics regarding this issue and can't find any solution that can help me with this especially with java client 8 + appium v 2.x !
i'm trying to get the text from my test class for ex. hello and try to past it into the iOS clipboard but unfortunately it seems the value is null or empty string ...
I'm using the following code language : java + selenium framework
all other topics regarding this issue is mentioning to use the following command :
https://appium.io/docs/en/commands/device/clipboard/set-clipboard/
driver.setClipboard("label", ClipboardContentType.PLAINTEXT, base64Content);
driver.setClipboardText("happy testing");
the previous command is not working with new Appiumdriver/driver since it's using java client 8 the method setClipboard is not listed there !
i tried the way they said to put the app in foreground but is not working for new appium 2.x + java client 8 since the most of the methods has been deprecated
Set the content of the system clipboard (For iOS 15+ real devices)
Apple security preferences require the WebDriverAgentRunner
application to be in foreground in order to set the system clipboard
content. Consider using Activate App and Background App to change the
foreground application. Activate App command cannot launch the
WebDriverAgent properly on some environments. It depends on XCTest
framework by Apple. Then, you should launch the WebDriverAgent using
its Springboard's application icon. Follow the example below. 1. Open
Springboard, #driver.activate_app 'com.apple.springboard'. 2. Find the
WDA icon with #driver.find_element :accessibility_id,
'WebDriverAgentRunner-Runner' (It should be visible on the screen) and
click it. 3. Call the get clipboard API. 4. Open the application under
test with the Activate App.
another way that i've tried :
How to use setClipboardText on Appium Java
((HasClipboard) driver).setClipboardText(“happy testing”);
still not sending any values !
tried this soultion :
https://stackoverflow.com/a/3592022/20274854
StringSelection selection = new StringSelection(theString);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);
it's working on when i paste the text from my Mac clipboard but still not sending any values to iOS !
plz can anyone help me with this ?
NOTE: i tried all the previous solutions but nothing are working with new Appium 2.x + java client 8
my problem has been solved
solution is :
https://appium.io/docs/en/commands/device/clipboard/set-clipboard/
++ Springboard is the internal function that launches apps when you tap on their icon on the Home screen. You can’t see it, but you use it every time you launch an app or switch apps

How to write Espresso view/data matchers in Appium Java Client?

I am using Appium to test Android application and today I was instructed to switch from UIAutomator2 to Espresso automator. I realized that it will not be so simple as just changing automator name.
As far as my searching go, Appium with Espresso automator have very little (almost none) documentation for writing selectors (view/data matchers) in Java/Kotlin.
I am trying to find out how to for example rewrite my current method for search by text. It looks like this:
(driver as AndroidDriver<*>).findElementByAndroidUIAutomator("new UiSelector().textContains(\"$text\")")
// Written for UIAutomator2
I tried:
(driver as AndroidDriver<*>).findElement(MobileBy.androidViewMatcher(Json().toJson(
ImmutableMap.of(
"name", "withText",
"args", ImmutableList.of("<text>"),
)
)))
But does not seems to work...
I see in appium-espresso-driver readme that I can search by text and by much more, but I cannot simply find a documentation how to send those commands to Appium Server trough Appium java client.
Any recommendations for docs, or help how to do it? Thanks

How to attach a chrome window to a desktop application Selenium?

My problem is when I click on a desktop icon, it opens a link in already opened chrome browser in a new tab. How do I attach with the already opened browser and not a new one?
The below code returns a null because there is no window opened through selenium ofcourse, so yeah.
Set<String> windows = webdriver.getWindowHandles();
System.out.println(windows);
Any suggestions would be of great help. Thanks In advance.
There is no way to attach the chrome window that you've opened from the desktop application to your WebDriver instance.
If you want to be able to control a web page with a Selenium - you must pass your URL to a driver like that:
webdriver.get("https://www.your_link.com");
You might think about the way of getting and storing your URL as a variable and passing it into your code.
That would also be helpful if you add a bit more details about the problem. It's a bit unclear at what stage of the test you open the web page with a desktop application. Selenium can't be used to test desktop applications. Code sample of the test from your project would also help.

Element found on appium studio doesn't work for appium standalone server and vice versa

The element which I am capturing via desktop inspector not working on appium studio and working fine when I run via appium stand alone server ?
-Is there any reason behind that?
-Any solution if I capture element from anywhere it works irrespective of any server?
-How to write relative xpath of below code ?
/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[1]
I am automating an app using appium, so via desktop inspector I captured some element. and when I ran the code it was working fine.
But for on xpath I used appium studio because in desktop inspector it was an absoulute xpath and it was quite long. but when I executed this script got failed on appium studio however it was working fine on appium standalone server.and same thing happened when I located the element via appium studio and tried to run on appium.
-Captured element cant run on both the server ?
//appium studio
driver.findElement(By.xpath("//*[#id='action_contacts']")).click();--
id -action_contacts
resource id - com.appName.chatapp:id/action_contacts
class - android.widget.FrameLayout
//Desktop inspector
driver.findElement(By.id("Contacts")).click();
accessibility id Contacts
id com.appName.chatapp:id/action_contacts
xpath //android.widget.FrameLayout[#content-desc="Contacts"]
An element could not be located on the page using the given search parameters.
The correct locators would be:
ID: driver.findElement(By.id("action_contacts")).click();
XPath: driver.findElement(By.xpath("//*[contains(#id,'action_contacts')]")).click();, you need to use contains() function in order to make a match on the partial text.

Unable to get Clickable button in UI Automator Viewer

I am trying to automate clickable button for a react-native based Application. I was stopped getting clickable button as in UI Automator Viewer displaying clickable button status FALSE. So, can you suggest me any other alternative way to automate the clickable action using Appium.
Using Selenium 3.5.3 version, Appium for Windows 1_4_16_1.
Image 1
Image2
First: start using appium-desktop and not an old appium server 1.4.16, but 1.7.x
Second: ReactNative app is interpreted as Native application, so you need to use Appium on client side, not Selenium
Final: In appium-desktop you can directly try to click your button to see if it works.

Categories

Resources