|
|
|
@ -11,15 +11,17 @@ import android.content.Intent
|
|
|
|
|
import android.net.Uri
|
|
|
|
|
import android.os.SystemClock
|
|
|
|
|
import android.util.Log
|
|
|
|
|
import android.widget.EditText
|
|
|
|
|
import android.widget.TimePicker
|
|
|
|
|
import androidx.test.espresso.Espresso.onView
|
|
|
|
|
import androidx.test.espresso.action.ViewActions
|
|
|
|
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
|
|
|
|
import androidx.test.espresso.contrib.PickerActions
|
|
|
|
|
import androidx.test.espresso.intent.Intents
|
|
|
|
|
import androidx.test.espresso.intent.matcher.BundleMatchers
|
|
|
|
|
import androidx.test.espresso.intent.matcher.IntentMatchers
|
|
|
|
|
import androidx.test.espresso.matcher.RootMatchers.isDialog
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
|
|
|
@ -27,6 +29,7 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
|
|
|
|
import androidx.test.uiautomator.By
|
|
|
|
|
import androidx.test.uiautomator.By.text
|
|
|
|
|
import androidx.test.uiautomator.UiObject
|
|
|
|
|
import androidx.test.uiautomator.UiObjectNotFoundException
|
|
|
|
|
import androidx.test.uiautomator.UiSelector
|
|
|
|
|
import androidx.test.uiautomator.Until
|
|
|
|
@ -34,6 +37,7 @@ import mozilla.components.browser.state.selector.selectedTab
|
|
|
|
|
import mozilla.components.browser.state.store.BrowserStore
|
|
|
|
|
import mozilla.components.concept.engine.mediasession.MediaSession
|
|
|
|
|
import org.hamcrest.CoreMatchers.allOf
|
|
|
|
|
import org.junit.Assert.assertFalse
|
|
|
|
|
import org.junit.Assert.assertTrue
|
|
|
|
|
import org.junit.Assert.fail
|
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
@ -43,11 +47,13 @@ import org.mozilla.fenix.helpers.Constants.RETRY_COUNT
|
|
|
|
|
import org.mozilla.fenix.helpers.SessionLoadedIdlingResource
|
|
|
|
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
|
|
|
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeLong
|
|
|
|
|
import org.mozilla.fenix.helpers.TestHelper.getStringResource
|
|
|
|
|
import org.mozilla.fenix.helpers.TestHelper.mDevice
|
|
|
|
|
import org.mozilla.fenix.helpers.TestHelper.packageName
|
|
|
|
|
import org.mozilla.fenix.helpers.TestHelper.waitForObjects
|
|
|
|
|
import org.mozilla.fenix.helpers.click
|
|
|
|
|
import org.mozilla.fenix.helpers.ext.waitNotNull
|
|
|
|
|
import java.time.LocalDate
|
|
|
|
|
|
|
|
|
|
class BrowserRobot {
|
|
|
|
|
private lateinit var sessionLoadedIdlingResource: SessionLoadedIdlingResource
|
|
|
|
@ -334,134 +340,54 @@ class BrowserRobot {
|
|
|
|
|
menuSaveImage.click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun createBookmark(url: Uri) {
|
|
|
|
|
fun createBookmark(url: Uri, folder: String? = null) {
|
|
|
|
|
navigationToolbar {
|
|
|
|
|
}.enterURLAndEnterToBrowser(url) {
|
|
|
|
|
// needs to wait for the right url to load before saving a bookmark
|
|
|
|
|
verifyUrl(url.toString())
|
|
|
|
|
}.openThreeDotMenu {
|
|
|
|
|
}.bookmarkPage { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickLinkMatchingText(expectedText: String) {
|
|
|
|
|
mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView"))
|
|
|
|
|
.waitForExists(waitingTime)
|
|
|
|
|
mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTimeLong)
|
|
|
|
|
|
|
|
|
|
val element = mDevice.findObject(UiSelector().textContains(expectedText))
|
|
|
|
|
element.click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun longClickMatchingText(expectedText: String) {
|
|
|
|
|
try {
|
|
|
|
|
mDevice.waitForWindowUpdate(packageName, waitingTime)
|
|
|
|
|
mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView"))
|
|
|
|
|
.waitForExists(waitingTime)
|
|
|
|
|
mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime)
|
|
|
|
|
val link = mDevice.findObject(By.textContains(expectedText))
|
|
|
|
|
link.click(LONG_CLICK_DURATION)
|
|
|
|
|
} catch (e: NullPointerException) {
|
|
|
|
|
println(e)
|
|
|
|
|
|
|
|
|
|
// Refresh the page in case the first long click didn't succeed
|
|
|
|
|
navigationToolbar {
|
|
|
|
|
}.openThreeDotMenu {
|
|
|
|
|
}.refreshPage {
|
|
|
|
|
mDevice.waitForIdle()
|
|
|
|
|
}.bookmarkPage {
|
|
|
|
|
}.takeIf { !folder.isNullOrBlank() }?.let {
|
|
|
|
|
it.openThreeDotMenu {
|
|
|
|
|
}.editBookmarkPage {
|
|
|
|
|
setParentFolder(folder!!)
|
|
|
|
|
saveEditBookmark()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Long click again the desired text
|
|
|
|
|
mDevice.waitForWindowUpdate(packageName, waitingTime)
|
|
|
|
|
mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView"))
|
|
|
|
|
.waitForExists(waitingTime)
|
|
|
|
|
mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime)
|
|
|
|
|
val link = mDevice.findObject(By.textContains(expectedText))
|
|
|
|
|
link.click(LONG_CLICK_DURATION)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun longClickAndCopyText(expectedText: String, selectAll: Boolean = false) {
|
|
|
|
|
try {
|
|
|
|
|
// Long click desired text
|
|
|
|
|
mDevice.waitForWindowUpdate(packageName, waitingTime)
|
|
|
|
|
mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView"))
|
|
|
|
|
.waitForExists(waitingTime)
|
|
|
|
|
mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime)
|
|
|
|
|
val link = mDevice.findObject(By.textContains(expectedText))
|
|
|
|
|
link.click(LONG_CLICK_DURATION)
|
|
|
|
|
|
|
|
|
|
// Click Select all from the text selection toolbar
|
|
|
|
|
if (selectAll) {
|
|
|
|
|
mDevice.findObject(UiSelector().textContains("Select all")).waitForExists(waitingTime)
|
|
|
|
|
val selectAllText = mDevice.findObject(By.textContains("Select all"))
|
|
|
|
|
selectAllText.click()
|
|
|
|
|
}
|
|
|
|
|
fun clickLinkMatchingText(expectedText: String) =
|
|
|
|
|
clickPageObject(webPageItemContainingText(expectedText))
|
|
|
|
|
|
|
|
|
|
// Click Copy from the text selection toolbar
|
|
|
|
|
mDevice.findObject(UiSelector().textContains("Copy")).waitForExists(waitingTime)
|
|
|
|
|
val copyText = mDevice.findObject(By.textContains("Copy"))
|
|
|
|
|
copyText.click()
|
|
|
|
|
} catch (e: NullPointerException) {
|
|
|
|
|
println("Failed to long click desired text: ${e.localizedMessage}")
|
|
|
|
|
|
|
|
|
|
// Refresh the page in case the first long click didn't succeed
|
|
|
|
|
navigationToolbar {
|
|
|
|
|
}.openThreeDotMenu {
|
|
|
|
|
}.refreshPage {
|
|
|
|
|
mDevice.waitForIdle()
|
|
|
|
|
}
|
|
|
|
|
fun longClickLink(expectedText: String) =
|
|
|
|
|
longClickPageObject(webPageItemWithText(expectedText))
|
|
|
|
|
|
|
|
|
|
// Long click again the desired text
|
|
|
|
|
mDevice.waitForWindowUpdate(packageName, waitingTime)
|
|
|
|
|
mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView"))
|
|
|
|
|
.waitForExists(waitingTime)
|
|
|
|
|
mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime)
|
|
|
|
|
val link = mDevice.findObject(By.textContains(expectedText))
|
|
|
|
|
link.click(LONG_CLICK_DURATION)
|
|
|
|
|
|
|
|
|
|
// Click again Select all from the text selection toolbar
|
|
|
|
|
if (selectAll) {
|
|
|
|
|
mDevice.findObject(UiSelector().textContains("Select all")).waitForExists(waitingTime)
|
|
|
|
|
val selectAllText = mDevice.findObject(By.textContains("Select all"))
|
|
|
|
|
selectAllText.click()
|
|
|
|
|
}
|
|
|
|
|
fun longClickMatchingText(expectedText: String) =
|
|
|
|
|
longClickPageObject(webPageItemContainingText(expectedText))
|
|
|
|
|
|
|
|
|
|
fun longClickAndCopyText(expectedText: String, selectAll: Boolean = false) {
|
|
|
|
|
longClickPageObject(webPageItemContainingText(expectedText))
|
|
|
|
|
|
|
|
|
|
// Click again Copy from the text selection toolbar
|
|
|
|
|
mDevice.findObject(UiSelector().textContains("Copy")).waitForExists(waitingTime)
|
|
|
|
|
val copyText = mDevice.findObject(By.textContains("Copy"))
|
|
|
|
|
copyText.click()
|
|
|
|
|
// Click Select all from the text selection toolbar
|
|
|
|
|
if (selectAll) {
|
|
|
|
|
mDevice.findObject(UiSelector().textContains("Select all")).waitForExists(waitingTime)
|
|
|
|
|
val selectAllText = mDevice.findObject(By.textContains("Select all"))
|
|
|
|
|
selectAllText.click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Click Copy from the text selection toolbar
|
|
|
|
|
mDevice.findObject(UiSelector().textContains("Copy")).waitForExists(waitingTime)
|
|
|
|
|
val copyText = mDevice.findObject(By.textContains("Copy"))
|
|
|
|
|
copyText.click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun longClickAndSearchText(searchButton: String, expectedText: String) {
|
|
|
|
|
var currentTries = 0
|
|
|
|
|
while (currentTries++ < 3) {
|
|
|
|
|
try {
|
|
|
|
|
// Long click desired text
|
|
|
|
|
mDevice.waitForWindowUpdate(packageName, waitingTime)
|
|
|
|
|
mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView"))
|
|
|
|
|
.waitForExists(waitingTime)
|
|
|
|
|
mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime)
|
|
|
|
|
val link = mDevice.findObject(By.textContains(expectedText))
|
|
|
|
|
link.click(LONG_CLICK_DURATION)
|
|
|
|
|
|
|
|
|
|
// Click search from the text selection toolbar
|
|
|
|
|
mDevice.findObject(UiSelector().textContains(searchButton)).waitForExists(waitingTime)
|
|
|
|
|
val searchText = mDevice.findObject(By.textContains(searchButton))
|
|
|
|
|
searchText.click()
|
|
|
|
|
longClickPageObject(webPageItemContainingText(expectedText))
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
} catch (e: NullPointerException) {
|
|
|
|
|
println("Failed to long click desired text: ${e.localizedMessage}")
|
|
|
|
|
|
|
|
|
|
// Refresh the page in case the first long click didn't succeed
|
|
|
|
|
navigationToolbar {
|
|
|
|
|
}.openThreeDotMenu {
|
|
|
|
|
}.refreshPage {
|
|
|
|
|
mDevice.waitForIdle()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Click search from the text selection toolbar
|
|
|
|
|
mDevice.findObject(UiSelector().textContains(searchButton)).waitForExists(waitingTime)
|
|
|
|
|
val searchText = mDevice.findObject(By.textContains(searchButton))
|
|
|
|
|
searchText.click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun snackBarButtonClick() {
|
|
|
|
@ -474,18 +400,10 @@ class BrowserRobot {
|
|
|
|
|
switchButton.clickAndWaitForNewWindow(waitingTime)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifySaveLoginPromptIsShown() {
|
|
|
|
|
mDevice.findObject(UiSelector().text("test@example.com")).waitForExists(waitingTime)
|
|
|
|
|
val submitButton = mDevice.findObject(By.res("submit"))
|
|
|
|
|
submitButton.clickAndWait(Until.newWindow(), waitingTime)
|
|
|
|
|
// Click save to save the login
|
|
|
|
|
mDevice.waitNotNull(Until.findObjects(text("Save")))
|
|
|
|
|
}
|
|
|
|
|
fun verifySaveLoginPromptIsShown() = clickPageObject(webPageItemWithResourceId("submit"))
|
|
|
|
|
|
|
|
|
|
fun verifyUpdateLoginPromptIsShown() {
|
|
|
|
|
val submitButton = mDevice.findObject(By.res("submit"))
|
|
|
|
|
submitButton.clickAndWait(Until.newWindow(), waitingTime)
|
|
|
|
|
|
|
|
|
|
clickPageObject(webPageItemWithResourceId("submit"))
|
|
|
|
|
mDevice.waitNotNull(Until.findObjects(text("Update")))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -499,49 +417,13 @@ class BrowserRobot {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun enterPassword(password: String) {
|
|
|
|
|
val passwordField = mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.resourceId("password")
|
|
|
|
|
.className(EditText::class.java),
|
|
|
|
|
)
|
|
|
|
|
try {
|
|
|
|
|
passwordField.waitForExists(waitingTime)
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
By
|
|
|
|
|
.res("password")
|
|
|
|
|
.clazz(EditText::class.java),
|
|
|
|
|
).click()
|
|
|
|
|
passwordField.clearTextField()
|
|
|
|
|
passwordField.text = password
|
|
|
|
|
// wait until the password is hidden
|
|
|
|
|
assertTrue(mDevice.findObject(UiSelector().text(password)).waitUntilGone(waitingTime))
|
|
|
|
|
} catch (e: UiObjectNotFoundException) {
|
|
|
|
|
println(e)
|
|
|
|
|
clickPageObject(webPageItemWithResourceId("password"))
|
|
|
|
|
setPageObjectText(webPageItemWithResourceId("password"), password)
|
|
|
|
|
|
|
|
|
|
// Lets refresh the page and try again
|
|
|
|
|
browserScreen {
|
|
|
|
|
}.openThreeDotMenu {
|
|
|
|
|
}.refreshPage {
|
|
|
|
|
mDevice.waitForIdle()
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
passwordField.waitForExists(waitingTime)
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
By
|
|
|
|
|
.res("password")
|
|
|
|
|
.clazz(EditText::class.java),
|
|
|
|
|
).click()
|
|
|
|
|
passwordField.clearTextField()
|
|
|
|
|
passwordField.text = password
|
|
|
|
|
// wait until the password is hidden
|
|
|
|
|
assertTrue(mDevice.findObject(UiSelector().text(password)).waitUntilGone(waitingTime))
|
|
|
|
|
}
|
|
|
|
|
assertTrue(mDevice.findObject(UiSelector().text(password)).waitUntilGone(waitingTime))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickMediaPlayerPlayButton() {
|
|
|
|
|
mediaPlayerPlayButton().waitForExists(waitingTime)
|
|
|
|
|
mediaPlayerPlayButton().click()
|
|
|
|
|
}
|
|
|
|
|
fun clickMediaPlayerPlayButton() = clickPageObject(webPageItemWithText("Play"))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the current playback state of the currently selected tab.
|
|
|
|
@ -605,26 +487,17 @@ class BrowserRobot {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun fillAndSubmitLoginCredentials(userName: String, password: String) {
|
|
|
|
|
var currentTries = 0
|
|
|
|
|
while (currentTries++ < 3) {
|
|
|
|
|
try {
|
|
|
|
|
mDevice.waitForIdle(waitingTime)
|
|
|
|
|
userNameTextBox.setText(userName)
|
|
|
|
|
passwordTextBox.setText(password)
|
|
|
|
|
submitLoginButton.click()
|
|
|
|
|
|
|
|
|
|
mDevice.waitForObjects(mDevice.findObject(UiSelector().resourceId("$packageName:id/save_confirm")))
|
|
|
|
|
mDevice.waitForIdle(waitingTime)
|
|
|
|
|
setPageObjectText(webPageItemWithResourceId("username"), userName)
|
|
|
|
|
setPageObjectText(webPageItemWithResourceId("password"), password)
|
|
|
|
|
clickPageObject(webPageItemWithResourceId("submit"))
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
} catch (e: UiObjectNotFoundException) {
|
|
|
|
|
Log.e("BROWSER_ROBOT", "Failed to find locator: ${e.localizedMessage}")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mDevice.waitForObjects(mDevice.findObject(UiSelector().resourceId("$packageName:id/save_confirm")))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clearUserNameLoginCredential() {
|
|
|
|
|
mDevice.waitForObjects(userNameTextBox)
|
|
|
|
|
userNameTextBox.clearTextField()
|
|
|
|
|
mDevice.waitForObjects(webPageItemWithResourceId("username"))
|
|
|
|
|
webPageItemWithResourceId("username").clearTextField()
|
|
|
|
|
mDevice.waitForIdle(waitingTime)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -637,25 +510,19 @@ class BrowserRobot {
|
|
|
|
|
mDevice.waitForObjects(suggestedLogins)
|
|
|
|
|
break
|
|
|
|
|
} catch (e: UiObjectNotFoundException) {
|
|
|
|
|
userNameTextBox.click()
|
|
|
|
|
clickPageObject(webPageItemWithResourceId("username"))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickStreetAddressTextBox() {
|
|
|
|
|
streetAddressTextBox().waitForExists(waitingTime)
|
|
|
|
|
streetAddressTextBox().click()
|
|
|
|
|
}
|
|
|
|
|
fun clickStreetAddressTextBox() = clickPageObject(webPageItemWithResourceId("streetAddress"))
|
|
|
|
|
|
|
|
|
|
fun clickSelectAddressButton() {
|
|
|
|
|
selectAddressButton.waitForExists(waitingTime)
|
|
|
|
|
selectAddressButton.clickAndWaitForNewWindow(waitingTime)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickCardNumberTextBox() {
|
|
|
|
|
creditCardNumberTextBox().waitForExists(waitingTime)
|
|
|
|
|
creditCardNumberTextBox().click()
|
|
|
|
|
}
|
|
|
|
|
fun clickCardNumberTextBox() = clickPageObject(webPageItemWithResourceId("cardNumber"))
|
|
|
|
|
|
|
|
|
|
fun clickSelectCreditCardButton() {
|
|
|
|
|
selectCreditCardButton.waitForExists(waitingTime)
|
|
|
|
@ -699,8 +566,8 @@ class BrowserRobot {
|
|
|
|
|
// Sometimes the assertion of the pre-filled logins fails so we are re-trying after refreshing the page
|
|
|
|
|
while (currentTries++ < 3) {
|
|
|
|
|
try {
|
|
|
|
|
mDevice.waitForObjects(userNameTextBox)
|
|
|
|
|
assertTrue(userNameTextBox.text.equals(userName))
|
|
|
|
|
mDevice.waitForObjects(webPageItemWithResourceId("username"))
|
|
|
|
|
assertTrue(webPageItemWithResourceId("username").text.equals(userName))
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
} catch (e: AssertionError) {
|
|
|
|
@ -714,18 +581,24 @@ class BrowserRobot {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mDevice.waitForObjects(userNameTextBox)
|
|
|
|
|
assertTrue(userNameTextBox.text.equals(userName))
|
|
|
|
|
mDevice.waitForObjects(webPageItemWithResourceId("username"))
|
|
|
|
|
assertTrue(webPageItemWithResourceId("username").text.equals(userName))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifyAutofilledAddress(streetAddress: String) {
|
|
|
|
|
mDevice.waitForObjects(streetAddressTextBox(streetAddress))
|
|
|
|
|
assertTrue(streetAddressTextBox(streetAddress).waitForExists(waitingTime))
|
|
|
|
|
mDevice.waitForObjects(webPageItemContainingTextAndResourceId("streetAddress", streetAddress))
|
|
|
|
|
assertTrue(
|
|
|
|
|
webPageItemContainingTextAndResourceId("streetAddress", streetAddress)
|
|
|
|
|
.waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifyAutofilledCreditCard(creditCardNumber: String) {
|
|
|
|
|
mDevice.waitForObjects(creditCardNumberTextBox(creditCardNumber))
|
|
|
|
|
assertTrue(creditCardNumberTextBox(creditCardNumber).waitForExists(waitingTime))
|
|
|
|
|
mDevice.waitForObjects(webPageItemContainingTextAndResourceId("cardNumber", creditCardNumber))
|
|
|
|
|
assertTrue(
|
|
|
|
|
webPageItemContainingTextAndResourceId("cardNumber", creditCardNumber)
|
|
|
|
|
.waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifyPrefilledPWALoginCredentials(userName: String, shortcutTitle: String) {
|
|
|
|
@ -734,9 +607,9 @@ class BrowserRobot {
|
|
|
|
|
var currentTries = 0
|
|
|
|
|
while (currentTries++ < 3) {
|
|
|
|
|
try {
|
|
|
|
|
assertTrue(submitLoginButton.waitForExists(waitingTime))
|
|
|
|
|
submitLoginButton.click()
|
|
|
|
|
assertTrue(userNameTextBox.text.equals(userName))
|
|
|
|
|
assertTrue(webPageItemWithResourceId("submit").waitForExists(waitingTime))
|
|
|
|
|
webPageItemWithResourceId("submit").click()
|
|
|
|
|
assertTrue(webPageItemWithResourceId("username").text.equals(userName))
|
|
|
|
|
break
|
|
|
|
|
} catch (e: AssertionError) {
|
|
|
|
|
addToHomeScreen {
|
|
|
|
@ -779,10 +652,236 @@ class BrowserRobot {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickSetCookiesButton() {
|
|
|
|
|
val setCookiesButton = mDevice.findObject(UiSelector().resourceId("setCookies"))
|
|
|
|
|
setCookiesButton.waitForExists(waitingTimeLong)
|
|
|
|
|
setCookiesButton.click()
|
|
|
|
|
fun clickSetCookiesButton() = clickPageObject(webPageItemWithResourceId("setCookies"))
|
|
|
|
|
|
|
|
|
|
fun verifyCookiesProtectionHint() {
|
|
|
|
|
val hintMessage =
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.textContains(getStringResource(R.string.tcp_cfr_message)),
|
|
|
|
|
)
|
|
|
|
|
assertTrue(hintMessage.waitForExists(waitingTime))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickForm(formType: String) {
|
|
|
|
|
when (formType) {
|
|
|
|
|
"Calendar Form" -> {
|
|
|
|
|
clickPageObject(webPageItemWithResourceId("calendar"))
|
|
|
|
|
mDevice.waitForIdle(waitingTime)
|
|
|
|
|
}
|
|
|
|
|
"Clock Form" -> {
|
|
|
|
|
clickPageObject(webPageItemWithResourceId("clock"))
|
|
|
|
|
mDevice.waitForIdle(waitingTime)
|
|
|
|
|
}
|
|
|
|
|
"Color Form" -> {
|
|
|
|
|
clickPageObject(webPageItemWithResourceId("colorPicker"))
|
|
|
|
|
mDevice.waitForIdle(waitingTime)
|
|
|
|
|
}
|
|
|
|
|
"Drop-down Form" -> {
|
|
|
|
|
clickPageObject(webPageItemWithResourceId("dropDown"))
|
|
|
|
|
mDevice.waitForIdle(waitingTime)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickFormViewButton(button: String) = mDevice.findObject(UiSelector().textContains(button)).click()
|
|
|
|
|
|
|
|
|
|
fun selectDate() {
|
|
|
|
|
mDevice.findObject(UiSelector().resourceId("android:id/month_view")).waitForExists(waitingTime)
|
|
|
|
|
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.textContains("$currentDay")
|
|
|
|
|
.descriptionContains("$currentDay $currentMonth $currentYear"),
|
|
|
|
|
).click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun selectTime(hour: Int, minute: Int) =
|
|
|
|
|
onView(
|
|
|
|
|
isAssignableFrom(TimePicker::class.java),
|
|
|
|
|
).inRoot(
|
|
|
|
|
isDialog(),
|
|
|
|
|
).perform(PickerActions.setTime(hour, minute))
|
|
|
|
|
|
|
|
|
|
fun selectColor(hexValue: String) {
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.textContains("Choose a color")
|
|
|
|
|
.resourceId("$packageName:id/alertTitle"),
|
|
|
|
|
).waitForExists(waitingTime)
|
|
|
|
|
|
|
|
|
|
val colorSelection =
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.resourceId("$packageName:id/color_item")
|
|
|
|
|
.descriptionContains(hexValue),
|
|
|
|
|
)
|
|
|
|
|
colorSelection.click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun selectDropDownOption(optionName: String) {
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector().resourceId("$packageName:id/customPanel"),
|
|
|
|
|
).waitForExists(waitingTime)
|
|
|
|
|
mDevice.findObject(UiSelector().textContains(optionName)).click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickSubmitDateButton() = clickPageObject(webPageItemWithResourceId("submitDate"))
|
|
|
|
|
|
|
|
|
|
fun clickSubmitTimeButton() = clickPageObject(webPageItemWithResourceId("submitTime"))
|
|
|
|
|
|
|
|
|
|
fun clickSubmitColorButton() = clickPageObject(webPageItemWithResourceId("submitColor"))
|
|
|
|
|
|
|
|
|
|
fun clickSubmitDropDownButton() = clickPageObject(webPageItemWithResourceId("submitOption"))
|
|
|
|
|
|
|
|
|
|
fun verifySelectedDate() {
|
|
|
|
|
for (i in 1..RETRY_COUNT) {
|
|
|
|
|
try {
|
|
|
|
|
assertTrue(
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.text("Selected date is: $currentDate"),
|
|
|
|
|
).waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
} catch (e: AssertionError) {
|
|
|
|
|
Log.e("TestLog", "Selected time isn't displayed ${e.localizedMessage}")
|
|
|
|
|
|
|
|
|
|
clickForm("Calendar Form")
|
|
|
|
|
selectDate()
|
|
|
|
|
clickFormViewButton("OK")
|
|
|
|
|
clickSubmitDateButton()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assertTrue(
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.text("Selected date is: $currentDate"),
|
|
|
|
|
).waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifyNoDateIsSelected() {
|
|
|
|
|
assertFalse(
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.text("Selected date is: $currentDate"),
|
|
|
|
|
).waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifySelectedTime(hour: Int, minute: Int) {
|
|
|
|
|
for (i in 1..RETRY_COUNT) {
|
|
|
|
|
try {
|
|
|
|
|
assertTrue(
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.text("Selected time is: $hour:$minute"),
|
|
|
|
|
).waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
} catch (e: AssertionError) {
|
|
|
|
|
Log.e("TestLog", "Selected time isn't displayed ${e.localizedMessage}")
|
|
|
|
|
|
|
|
|
|
clickForm("Clock Form")
|
|
|
|
|
clickFormViewButton("CLEAR")
|
|
|
|
|
clickForm("Clock Form")
|
|
|
|
|
selectTime(hour, minute)
|
|
|
|
|
clickFormViewButton("OK")
|
|
|
|
|
clickSubmitTimeButton()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assertTrue(
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.text("Selected time is: $hour:$minute"),
|
|
|
|
|
).waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifySelectedColor(hexValue: String) {
|
|
|
|
|
for (i in 1..RETRY_COUNT) {
|
|
|
|
|
try {
|
|
|
|
|
assertTrue(
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.text("Selected color is: $hexValue"),
|
|
|
|
|
).waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
} catch (e: AssertionError) {
|
|
|
|
|
Log.e("TestLog", "Selected color isn't displayed ${e.localizedMessage}")
|
|
|
|
|
|
|
|
|
|
clickForm("Color Form")
|
|
|
|
|
selectColor(hexValue)
|
|
|
|
|
clickFormViewButton("SET")
|
|
|
|
|
clickSubmitColorButton()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assertTrue(
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.text("Selected color is: $hexValue"),
|
|
|
|
|
).waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifySelectedDropDownOption(optionName: String) {
|
|
|
|
|
for (i in 1..RETRY_COUNT) {
|
|
|
|
|
try {
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.textContains("Submit drop down option")
|
|
|
|
|
.resourceId("submitOption"),
|
|
|
|
|
).waitForExists(waitingTime)
|
|
|
|
|
|
|
|
|
|
assertTrue(
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.text("Selected option is: $optionName"),
|
|
|
|
|
).waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
} catch (e: AssertionError) {
|
|
|
|
|
Log.e("TestLog", "Selected option isn't displayed ${e.localizedMessage}")
|
|
|
|
|
|
|
|
|
|
clickForm("Drop-down Form")
|
|
|
|
|
selectDropDownOption(optionName)
|
|
|
|
|
clickSubmitDropDownButton()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assertTrue(
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.text("Selected option is: $optionName"),
|
|
|
|
|
).waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifyNoTimeIsSelected(hour: Int, minute: Int) {
|
|
|
|
|
assertFalse(
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.text("Selected date is: $hour:$minute"),
|
|
|
|
|
).waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifyColorIsNotSelected(hexValue: String) {
|
|
|
|
|
assertFalse(
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.text("Selected date is: $hexValue"),
|
|
|
|
|
).waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Transition {
|
|
|
|
@ -812,12 +911,22 @@ class BrowserRobot {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun openTabDrawer(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector().descriptionContains("Tap to switch tabs."),
|
|
|
|
|
).waitForExists(waitingTime)
|
|
|
|
|
mDevice.waitForObjects(
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.resourceId("$packageName:id/mozac_browser_toolbar_browser_actions"),
|
|
|
|
|
),
|
|
|
|
|
waitingTime,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
tabsCounter().click()
|
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.res("$packageName:id/tab_layout")))
|
|
|
|
|
|
|
|
|
|
mDevice.waitForObjects(
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector().resourceId("$packageName:id/new_tab_button"),
|
|
|
|
|
),
|
|
|
|
|
waitingTime,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
TabDrawerRobot().interact()
|
|
|
|
|
return TabDrawerRobot.Transition()
|
|
|
|
@ -850,7 +959,12 @@ class BrowserRobot {
|
|
|
|
|
|
|
|
|
|
assertTrue(
|
|
|
|
|
mDevice.findObject(UiSelector().resourceId("$packageName:id/homeLayout"))
|
|
|
|
|
.waitForExists(waitingTime),
|
|
|
|
|
.waitForExists(waitingTime) ||
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector().text(
|
|
|
|
|
getStringResource(R.string.onboarding_home_screen_jump_back_contextual_hint_2),
|
|
|
|
|
),
|
|
|
|
|
).waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
HomeScreenRobot().interact()
|
|
|
|
@ -888,13 +1002,12 @@ class BrowserRobot {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickDownloadLink(title: String, interact: DownloadRobot.() -> Unit): DownloadRobot.Transition {
|
|
|
|
|
val downloadLink = mDevice.findObject(UiSelector().textContains(title))
|
|
|
|
|
|
|
|
|
|
assertTrue(
|
|
|
|
|
"$title download link not found",
|
|
|
|
|
downloadLink.waitForExists(waitingTime),
|
|
|
|
|
webPageItemContainingText(title).waitForExists(waitingTime),
|
|
|
|
|
)
|
|
|
|
|
downloadLink.click()
|
|
|
|
|
|
|
|
|
|
clickPageObject(webPageItemContainingText(title))
|
|
|
|
|
|
|
|
|
|
DownloadRobot().interact()
|
|
|
|
|
return DownloadRobot.Transition()
|
|
|
|
@ -902,8 +1015,7 @@ class BrowserRobot {
|
|
|
|
|
|
|
|
|
|
fun clickStartCameraButton(interact: SitePermissionsRobot.() -> Unit): SitePermissionsRobot.Transition {
|
|
|
|
|
// Test page used for testing permissions located at https://mozilla-mobile.github.io/testapp/permissions
|
|
|
|
|
cameraButton.waitForExists(waitingTime)
|
|
|
|
|
cameraButton.click()
|
|
|
|
|
clickPageObject(webPageItemWithText("Open camera"))
|
|
|
|
|
|
|
|
|
|
SitePermissionsRobot().interact()
|
|
|
|
|
return SitePermissionsRobot.Transition()
|
|
|
|
@ -911,8 +1023,7 @@ class BrowserRobot {
|
|
|
|
|
|
|
|
|
|
fun clickStartMicrophoneButton(interact: SitePermissionsRobot.() -> Unit): SitePermissionsRobot.Transition {
|
|
|
|
|
// Test page used for testing permissions located at https://mozilla-mobile.github.io/testapp/permissions
|
|
|
|
|
microphoneButton.waitForExists(waitingTime)
|
|
|
|
|
microphoneButton.click()
|
|
|
|
|
clickPageObject(webPageItemWithText("Open microphone"))
|
|
|
|
|
|
|
|
|
|
SitePermissionsRobot().interact()
|
|
|
|
|
return SitePermissionsRobot.Transition()
|
|
|
|
@ -920,8 +1031,7 @@ class BrowserRobot {
|
|
|
|
|
|
|
|
|
|
fun clickStartAudioVideoButton(interact: SitePermissionsRobot.() -> Unit): SitePermissionsRobot.Transition {
|
|
|
|
|
// Test page used for testing permissions located at https://mozilla-mobile.github.io/testapp/permissions
|
|
|
|
|
audioVideoButton.waitForExists(waitingTime)
|
|
|
|
|
audioVideoButton.click()
|
|
|
|
|
clickPageObject(webPageItemWithText("Camera & Microphone"))
|
|
|
|
|
|
|
|
|
|
SitePermissionsRobot().interact()
|
|
|
|
|
return SitePermissionsRobot.Transition()
|
|
|
|
@ -929,8 +1039,7 @@ class BrowserRobot {
|
|
|
|
|
|
|
|
|
|
fun clickOpenNotificationButton(interact: SitePermissionsRobot.() -> Unit): SitePermissionsRobot.Transition {
|
|
|
|
|
// Test page used for testing permissions located at https://mozilla-mobile.github.io/testapp/permissions
|
|
|
|
|
notificationButton.waitForExists(waitingTime)
|
|
|
|
|
notificationButton.click()
|
|
|
|
|
clickPageObject(webPageItemWithText("Open notifications dialogue"))
|
|
|
|
|
mDevice.waitForObjects(mDevice.findObject(UiSelector().textContains("Allow to send notifications?")))
|
|
|
|
|
|
|
|
|
|
SitePermissionsRobot().interact()
|
|
|
|
@ -939,8 +1048,14 @@ class BrowserRobot {
|
|
|
|
|
|
|
|
|
|
fun clickGetLocationButton(interact: SitePermissionsRobot.() -> Unit): SitePermissionsRobot.Transition {
|
|
|
|
|
// Test page used for testing permissions located at https://mozilla-mobile.github.io/testapp/permissions
|
|
|
|
|
getLocationButton.waitForExists(waitingTime)
|
|
|
|
|
getLocationButton.click()
|
|
|
|
|
clickPageObject(webPageItemWithText("Get Location"))
|
|
|
|
|
|
|
|
|
|
SitePermissionsRobot().interact()
|
|
|
|
|
return SitePermissionsRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickRequestStorageAccessButton(interact: SitePermissionsRobot.() -> Unit): SitePermissionsRobot.Transition {
|
|
|
|
|
clickPageObject(webPageItemContainingText("requestStorageAccess()"))
|
|
|
|
|
|
|
|
|
|
SitePermissionsRobot().interact()
|
|
|
|
|
return SitePermissionsRobot.Transition()
|
|
|
|
@ -988,14 +1103,8 @@ private fun assertMenuButton() {
|
|
|
|
|
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun tabsCounter() = mDevice.findObject(By.res("$packageName:id/counter_root"))
|
|
|
|
|
|
|
|
|
|
private fun mediaPlayerPlayButton() =
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.className("android.widget.Button")
|
|
|
|
|
.text("Play"),
|
|
|
|
|
)
|
|
|
|
|
private fun tabsCounter() =
|
|
|
|
|
mDevice.findObject(By.res("$packageName:id/mozac_browser_toolbar_browser_actions"))
|
|
|
|
|
|
|
|
|
|
private var progressBar =
|
|
|
|
|
mDevice.findObject(
|
|
|
|
@ -1013,24 +1122,6 @@ private fun addressSuggestion(streetName: String) =
|
|
|
|
|
.textContains(streetName),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
private fun streetAddressTextBox(streetAddress: String = "") =
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.resourceId("streetAddress")
|
|
|
|
|
.textContains(streetAddress)
|
|
|
|
|
.className("android.widget.EditText")
|
|
|
|
|
.packageName("$packageName"),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
private fun creditCardNumberTextBox(creditCardNumber: String = "") =
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.resourceId("cardNumber")
|
|
|
|
|
.textContains(creditCardNumber)
|
|
|
|
|
.className("android.widget.EditText")
|
|
|
|
|
.packageName("$packageName"),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
private fun creditCardSuggestion(creditCardNumber: String) =
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
@ -1041,41 +1132,92 @@ private fun creditCardSuggestion(creditCardNumber: String) =
|
|
|
|
|
private fun siteSecurityToolbarButton() =
|
|
|
|
|
mDevice.findObject(UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_security_indicator"))
|
|
|
|
|
|
|
|
|
|
// Permissions test page elements & prompts
|
|
|
|
|
// Test page used located at https://mozilla-mobile.github.io/testapp/permissions
|
|
|
|
|
private val cameraButton = mDevice.findObject(UiSelector().text("Open camera"))
|
|
|
|
|
private fun clickPageObject(webPageItem: UiObject) {
|
|
|
|
|
for (i in 1..RETRY_COUNT) {
|
|
|
|
|
try {
|
|
|
|
|
webPageItem.also {
|
|
|
|
|
it.waitForExists(waitingTime)
|
|
|
|
|
it.click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private val microphoneButton = mDevice.findObject(UiSelector().text("Open microphone"))
|
|
|
|
|
break
|
|
|
|
|
} catch (e: UiObjectNotFoundException) {
|
|
|
|
|
if (i == RETRY_COUNT) {
|
|
|
|
|
throw e
|
|
|
|
|
} else {
|
|
|
|
|
browserScreen {
|
|
|
|
|
}.openThreeDotMenu {
|
|
|
|
|
}.refreshPage {
|
|
|
|
|
progressBar.waitUntilGone(waitingTime)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private val audioVideoButton = mDevice.findObject(UiSelector().text("Camera & Microphone"))
|
|
|
|
|
fun longClickPageObject(webPageItem: UiObject) {
|
|
|
|
|
for (i in 1..RETRY_COUNT) {
|
|
|
|
|
try {
|
|
|
|
|
webPageItem.also {
|
|
|
|
|
it.waitForExists(waitingTime)
|
|
|
|
|
it.longClick()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private val notificationButton = mDevice.findObject(UiSelector().text("Open notifications dialogue"))
|
|
|
|
|
break
|
|
|
|
|
} catch (e: UiObjectNotFoundException) {
|
|
|
|
|
if (i == RETRY_COUNT) {
|
|
|
|
|
throw e
|
|
|
|
|
} else {
|
|
|
|
|
browserScreen {
|
|
|
|
|
}.openThreeDotMenu {
|
|
|
|
|
}.refreshPage {
|
|
|
|
|
}
|
|
|
|
|
progressBar.waitUntilGone(waitingTime)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private val getLocationButton = mDevice.findObject(UiSelector().text("Get Location"))
|
|
|
|
|
private fun webPageItemContainingText(itemText: String) =
|
|
|
|
|
mDevice.findObject(UiSelector().textContains(itemText))
|
|
|
|
|
|
|
|
|
|
// Login form test page elements
|
|
|
|
|
// Test page used located at https://mozilla-mobile.github.io/testapp/loginForm
|
|
|
|
|
val userNameTextBox =
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.resourceId("username")
|
|
|
|
|
.className("android.widget.EditText")
|
|
|
|
|
.packageName("$packageName"),
|
|
|
|
|
)
|
|
|
|
|
private fun webPageItemWithText(itemText: String) =
|
|
|
|
|
mDevice.findObject(UiSelector().text(itemText))
|
|
|
|
|
|
|
|
|
|
private val submitLoginButton =
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.resourceId("submit")
|
|
|
|
|
.textContains("Submit Query")
|
|
|
|
|
.className("android.widget.Button")
|
|
|
|
|
.packageName("$packageName"),
|
|
|
|
|
)
|
|
|
|
|
private fun webPageItemWithResourceId(resourceId: String) =
|
|
|
|
|
mDevice.findObject(UiSelector().resourceId(resourceId))
|
|
|
|
|
|
|
|
|
|
val passwordTextBox =
|
|
|
|
|
private fun webPageItemContainingTextAndResourceId(resourceId: String, itemText: String) =
|
|
|
|
|
mDevice.findObject(
|
|
|
|
|
UiSelector()
|
|
|
|
|
.resourceId("password")
|
|
|
|
|
.className("android.widget.EditText")
|
|
|
|
|
.packageName("$packageName"),
|
|
|
|
|
.resourceId(resourceId)
|
|
|
|
|
.textContains(itemText),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
private fun setPageObjectText(webPageItem: UiObject, text: String) {
|
|
|
|
|
for (i in 1..RETRY_COUNT) {
|
|
|
|
|
try {
|
|
|
|
|
webPageItem.also {
|
|
|
|
|
it.waitForExists(waitingTime)
|
|
|
|
|
it.setText(text)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
} catch (e: UiObjectNotFoundException) {
|
|
|
|
|
if (i == RETRY_COUNT) {
|
|
|
|
|
throw e
|
|
|
|
|
} else {
|
|
|
|
|
browserScreen {
|
|
|
|
|
}.openThreeDotMenu {
|
|
|
|
|
}.refreshPage {
|
|
|
|
|
progressBar.waitUntilGone(waitingTime)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private val currentDate = LocalDate.now()
|
|
|
|
|
private val currentDay = currentDate.dayOfMonth
|
|
|
|
|
private val currentMonth = currentDate.month
|
|
|
|
|
private val currentYear = currentDate.year
|
|
|
|
|