Repository: android/nowinandroid
Issue: [Bug]: Running MacroBenchmark Throw NullPointerException on interestsScrollTopicsDownUp

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is there a StackOverflow question about this issue?

- [X] I have searched StackOverflow

### What happened?

This PR is part of [GTC](https://www.facebook.com/groups/gazatechcommunity/) open source initiative

After run Genrate Baseline Profile I face exception
it looks like the emulator device stop before the interestsScrollTopicsDownUp happened

### Relevant logcat output

```shell
java.lang.NullPointerException
	at com.google.samples.apps.nowinandroid.interests.InterestsActionsKt.interestsScrollTopicsDownUp(InterestsActions.kt:38)
	at com.google.samples.apps.nowinandroid.baselineprofile.BaselineProfileGenerator$generate$1.invoke(BaselineProfileGenerator.kt:56)
	at com.google.samples.apps.nowinandroid.baselineprofile.BaselineProfileGenerator$generate$1.invoke(BaselineProfileGenerator.kt:38)
	at androidx.benchmark.macro.BaselineProfilesKt$collect$1$1.invoke(BaselineProfiles.kt:77)
	at androidx.benchmark.macro.BaselineProfilesKt$collect$1$1.invoke(BaselineProfiles.kt:71)
	at androidx.benchmark.macro.CompilationMode$Partial.compileImpl$benchmark_macro_release(CompilationMode.kt:319)
	at androidx.benchmark.macro.CompilationMode.resetAndCompile$benchmark_macro_release(CompilationMode.kt:115)
	at androidx.benchmark.macro.BaselineProfilesKt.collect(BaselineProfiles.kt:71)
	at androidx.benchmark.macro.junit4.BaselineProfileRule.collect(BaselineProfileRule.kt:136)
	at androidx.benchmark.macro.junit4.BaselineProfileRule.collect$default(BaselineProfileRule.kt:126)
	at com.google.samples.apps.nowinandroid.baselineprofile.BaselineProfileGenerator.generate(BaselineProfileGenerator.kt:38)
```


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Changed files:
benchmarks/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.kt
benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt

diff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.kt
index b544fbde..7a08bc63 100644
--- a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.kt
+++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.kt
@@ -18,6 +18,7 @@ package com.google.samples.apps.nowinandroid.baselineprofile
 
 import androidx.benchmark.macro.junit4.BaselineProfileRule
 import com.google.samples.apps.nowinandroid.PACKAGE_NAME
+import com.google.samples.apps.nowinandroid.allowNotifications
 import com.google.samples.apps.nowinandroid.bookmarks.goToBookmarksScreen
 import com.google.samples.apps.nowinandroid.foryou.forYouScrollFeedDownUp
 import com.google.samples.apps.nowinandroid.foryou.forYouSelectTopics
@@ -42,6 +43,7 @@ class BaselineProfileGenerator {
 
             pressHome()
             startActivityAndWait()
+            allowNotifications()
 
             // Scroll the feed critical user journey
             forYouWaitForContent()
diff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt
index e94369ce..d9c563eb 100644
--- a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt
+++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt
@@ -34,7 +34,7 @@ fun MacrobenchmarkScope.goToInterestsScreen() {
 }
 
 fun MacrobenchmarkScope.interestsScrollTopicsDownUp() {
-    val topicsList = device.findObject(By.res("interests:topics"))
+    val topicsList = device.wait(Until.findObject(By.res("interests:topics")), 2_000)
     device.flingElementDownUp(topicsList)
 }