Skip to content

iOS media handling changes #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

Miki-Session
Copy link
Collaborator

  • Simulators are erased before booting
  • Media sending functions generally push first and expect the file to be present
  • This completes the changes brought in by Android 1.23.0 changes #40

// Checking Sent status on both platforms
await this.waitForTextElementToBePresent({
...new OutgoingMessageStatusSent(this).build(),
maxWait: 50000,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

50s?

// Simulators are cleared on start of a test run to minimize device bloat
// This has to be done before starting them because you can't erase booted simulators
// If a simulator is already running this fails silently
await runScriptAndLog(`xcrun simctl erase ${udid}`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for many tests/simulators do we need to erase the data? Just wondering if there is a better way to do this, more reliably.
As in, we always push the file/media from the first device for each tests that need it, right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, I think this may need to be removed. The enormous time bloat is far outweighing the problem of having a flaky locator for media.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on a different approach that could allow us to not rely on any set dates for accessibility IDs (which was the whole point of this refactor)
If that works out (🤞🏻) we might get away with having a simple cronjob on the CI that periodically wipes all iOS simulators, just to minimize device bloat.

// Simulators are cleared on start of a test run to minimize device bloat
// This has to be done before starting them because you can't erase booted simulators
// If a simulator is already running this fails silently
await runScriptAndLog(`xcrun simctl erase ${udid}`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, I think this may need to be removed. The enormous time bloat is far outweighing the problem of having a flaky locator for media.

Comment on lines +1275 to +1280
await runScriptAndLog(`xcrun simctl openurl ${this.udid} ${pdfURL}`, true);
// Safari is open but now the file must be downloaded
await this.clickOnElementAll(new SafariShareButton(this));
await this.clickOnElementAll(new IOSSaveToFiles(this));
await this.clickOnElementAll(new IOSSaveButton(this));
// If for some weird reason the file is already present (but not found in the file picker)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this test about 10 times (Send document 1:1 @ios) and it only passed twice. This function needs tweaking

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran the test 10x on my end from a cold boot and the only time it failed, it failed way before the attachment sending part. I suspect Safari has a different flow on 17.5 and 17.2 (and 18.x probably) - gonna have another look

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: this works consistently on my 17.2 and 17.5 simulators but not 18.x

await this.clickOnElementAll(new UserSettings(this));
// Click on Profile picture
await this.clickOnElementAll(new UserSettings(this));
await this.clickOnElementAll(new ChangeProfilePictureButton(this));
if (this.isIOS()) {
// Push file first
await this.pushMediaToDevice(profilePicture, forcedDate);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test failed every time I ran it, need to revisit this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change profile picture

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to know where this fails on your end because I'm getting 100% pass rate with 10 repeats on my end. I'll run them on 17.2 and 18.x to be safe.

Copy link
Collaborator Author

@Miki-Session Miki-Session May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the locator is am and AM depending on locale

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new image matching approach completely eliminates this problem

}
await alice1.onIOS().clickOnByAccessibilityID('Photo, 25 March, 11:09 am', 1000);
await matchAndTapImage(
alice1.onIOS(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this onIOS for?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, should we move this function to the DeviceWrapper class directly?

@@ -20,6 +20,7 @@
"devDependencies": {
"@appium/execute-driver-plugin": "^3.0.1",
"@appium/images-plugin": "^3.0.17",
"@appium/opencv": "^3.0.9",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot do the same with the image matching that playwright offers?
I guess not because

  • this will not just look for a buffer that looks like another one,
  • but will actually try to find in a buffer, a part that looks like another one. Is that it?

const center = {
x: rect.x + Math.floor(rect.width / 2),
y: rect.y + Math.floor(rect.height / 2),
confidence: score,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the confidence field can be removed, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants