appium / appium-mac2-driver

Next-gen Appium macOS driver, backed by Apple XCTest
Apache License 2.0
115 stars 24 forks source link

how can I find the component after multi App is launch #285

Open HaoWShi opened 4 months ago

HaoWShi commented 4 months ago

In my scenario, I need to open different apps, such as settings and notes, then I will find and click on the component in settings, and then go to notes to find and click on the component. I found some the question, When I launchApp settings firstly, and launchApp notes secondly, I can find component of notes, but can not find component of setting even if setting ui is visible on the screen

KazuCocoa commented 4 months ago

Does the page source shows the most front app only? this driver depends on XCTest framework. I wonder if the XCTest framework can find elements/interact with elements that is on the top. Coordinate-based interaction would work for all cases, though.

HaoWShi commented 4 months ago

this is my test demo ` def test_startMultiApp(driver): time.sleep(2) driver.execute_script('macos: terminateApp', { 'bundleId': 'com.apple.systempreferences' }) time.sleep(2) driver.execute_script('macos: terminateApp', { 'bundleId': 'com.apple.iCal' }) time.sleep(2) driver.execute_script('macos: launchApp', { 'bundleId': 'com.apple.systempreferences' }) time.sleep(2) sourceSetting = driver.page_source file = open("launchSetting.txt", "w", encoding='utf-8') file.write(sourceSetting) file.close()

find notify

notify = driver.find_element(by=AppiumBy.IOS_PREDICATE, value='value=="通知" and elementType==48')
time.sleep(2)
driver.execute_script('macos: launchApp', {
    'bundleId': 'com.apple.iCal'
})
time.sleep(2)
sourceSetting2 = driver.page_source
file2 = open("launchSettingAndiCal.txt", "w", encoding='utf-8')
file2.write(sourceSetting2)
file2.close()
week = driver.find_element(by=AppiumBy.IOS_PREDICATE, value='label=="周" and elementType==10')
time.sleep(2)
notify = driver.find_element(by=AppiumBy.IOS_PREDICATE, value='value=="通知" and elementType==48')
time.sleep(2)

`

I add source and appium log appiumLog.txt launchSetting.txt launchSettingAndiCal.txt

HaoWShi commented 4 months ago

I think I get some advice form this: https://discuss.appium.io/t/trying-to-work-with-2-drivers-at-a-time-for-macos-application/41797 But I have a question now, If I call launchAPP or activeApp repeatedly, what is the error code? Is this a recommended procedure?