I am automating an Ionic framework app, I have a feature where I click on a button and a modal shows up with button of text “Save”, but clicking on it clicks a button which is behind the modal which is also a button with text “Save”.
I am using XPath "//*[contains(@text,‘Save’)] since we don’t have accessibility ids and single codebase for both iOS and Android.
I am forced to use NATIVE context although entire app is inspectable with chrome in the debug version of same app(like a WEBVIEW) because of client requirement to run the tests in the release builds.
When running the test separately, the page_source(as I checked with driver.page_source) has only one “Save” button and clicks the modal one perfectly fine
When running the test file with multiple tests, the page_source has two Save buttons and appium clicks on unintended Save button
How to deal with the issue? I am clueless, if I use instance [2], it will fail when running single test case, if I don’t use instance, it will not work when running as suite.
I managed to get it working by finding the required button as
//[contains(@text,‘Save’) and contains(@class,‘Button’) and ancestor::[contains(@class, ‘Dialog’)]]
Thanks for the reply, but I still couldn’t figure out why page source has the elements hidden behind the android.app.Dialog when entire test suite is run, but when run as single test, the page source has only the elements in the android.app.Dialog.