|
8 | 8 | import androidx.annotation.StringRes; |
9 | 9 | import androidx.appcompat.widget.SwitchCompat; |
10 | 10 | import androidx.appcompat.widget.Toolbar; |
| 11 | +import androidx.test.core.app.ApplicationProvider; |
11 | 12 | import androidx.test.espresso.UiController; |
12 | 13 | import androidx.test.espresso.ViewAction; |
13 | 14 | import androidx.test.espresso.ViewInteraction; |
|
20 | 21 |
|
21 | 22 | import static androidx.test.espresso.Espresso.onData; |
22 | 23 | import static androidx.test.espresso.Espresso.onView; |
| 24 | +import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu; |
23 | 25 | import static androidx.test.espresso.action.ViewActions.click; |
24 | 26 | import static androidx.test.espresso.assertion.ViewAssertions.matches; |
25 | 27 | import static androidx.test.espresso.contrib.RecyclerViewActions.actionOnItem; |
@@ -81,7 +83,14 @@ public void startNewPost() { |
81 | 83 |
|
82 | 84 | public void startNewSite() { |
83 | 85 | switchSite(); |
84 | | - clickOn(R.id.menu_add); |
| 86 | + // If the device has a narrower display, the menu_add is hidden in the overflow |
| 87 | + if (isElementDisplayed(R.id.menu_add)) { |
| 88 | + clickOn(R.id.menu_add); |
| 89 | + } else { |
| 90 | + // open the overflow and then click on the item with text |
| 91 | + openActionBarOverflowOrOptionsMenu(ApplicationProvider.getApplicationContext()); |
| 92 | + onView(withText(getTranslatedString(R.string.site_picker_add_site))).perform(click()); |
| 93 | + } |
85 | 94 | } |
86 | 95 |
|
87 | 96 | public void goToSettings() { |
|
0 commit comments