Skip to content

Commit

Permalink
comments for modal clicks
Browse files Browse the repository at this point in the history
  • Loading branch information
grablack committed Aug 28, 2024
1 parent dbad550 commit eff4d19
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 33 deletions.
82 changes: 58 additions & 24 deletions demo/src/androidTest/java/com/paypal/messagesdemo/XmlDemoTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.espresso.web.sugar.Web.onWebView
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.paypal.messages.R
Expand Down Expand Up @@ -310,18 +309,14 @@ public class XmlDemoLongTermTest : XmlDemoSetup() {
waitForApp(500)
clickMessage()
checkPayMonthlyContent()
waitForApp(5000)

onWebView().forceJavascriptEnabled()
waitForApp(500)

modalContent("Find more disclosures")

clickDisclosure()
waitForApp(50000)

// pressBack()
// waitForApp(5000)

// Iframe clicks not working
// clickDisclosure()
// Espresso.pressBack()
// waitForApp(500)
// checkPayMonthlyContent()
}
}
Expand Down Expand Up @@ -393,10 +388,11 @@ public class XmlDemoNiTest : XmlDemoSetup() {
waitForApp(1000)
checkMessage("%paypal_logo% No Interest")
clickMessage()
waitForApp(1000)
waitForApp(2000)
modalContent("Apply now")
clickApplyNow()
waitForApp(20000)
// Clicking iframe button not working
// waitForApp(1000)
// clickApplyNow()
// Espresso.pressBack()
// waitForApp(1000)
// modalContent("Apply now")
Expand All @@ -411,7 +407,7 @@ public class XmlDemoNiTest : XmlDemoSetup() {
checkMessage("%paypal_logo% No Interest")
clickMessage()
waitForApp(1000)
// modalContent("Apply now")
modalContent("Apply now")
// clickApplyNow()
// waitForApp(20000)
// Espresso.pressBack()
Expand Down Expand Up @@ -491,20 +487,58 @@ public class XmlDemoStyleOptionsTest : XmlDemoSetup() {
}
}

// TODO - Need to change client id via secrets
// @RunWith(AndroidJUnit4ClassRunner::class)
// public class XmlDemoCrossBorderTest : XmlDemoSetup() {
//
// // @Test
// // fun testCrossBorder(){
//
// // }
// }

@RunWith(AndroidJUnit4ClassRunner::class)
public class XmlDemoCrossBorderTest : XmlDemoSetup() {
public class XmlDemoEligibilityTest : XmlDemoSetup() {

// @Test
// fun testCrossBorder(){
@Test
fun testStandardConfig() {
waitForApp(500)

// }
}
checkMessage("Buy now")
typeAmount("20")
submit()
waitForApp(1000)
checkMessage("-")
clearAmount()

@RunWith(AndroidJUnit4ClassRunner::class)
public class XmlDemoEligibilityTest : XmlDemoSetup() {
typeAmount("50")
submit()
waitForApp(1000)
checkMessage("12.50")
clearAmount()

typeAmount("2000")
submit()
waitForApp(1000)
checkMessage("107.73")
clearAmount()

typeAmount("100000")
submit()
waitForApp(1000)
checkMessage("-")

// @Test
// fun testCrossBorder(){
clickMessage()
waitForApp(1000)
clickSeeOtherModalOptions()
clickPi4Tile()
waitForApp(500)
clickSeeOtherModalOptions()
clickNiTile()
waitForApp(500)
clickSeeOtherModalOptions()
clickPayMonthlyTile()
}

// }
// TODO - Need to change client ids for other tests
}
15 changes: 6 additions & 9 deletions demo/src/androidTest/java/common/EsspressoUi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,7 @@ fun clickSeeOtherModalOptions() {
fun clickDisclosure() {
onWebView(
ViewMatchers.withId(R.id.ModalWebView),
).withElement(DriverAtoms.findElement(Locator.XPATH, "/html/body/div/div[3]/div/div[5]/main/div/div[2]/a")).perform(DriverAtoms.webClick())
// onWebView(
// ViewMatchers.withId(R.id.ModalWebView),
// ).forceJavascriptEnabled().withElement(DriverAtoms.findElement(Locator.XPATH, "/html/body/div/div[3]/div/div[5]/main/div/div[2]/a")).perform(DriverAtoms.webClick())
).withElement(DriverAtoms.findElement(Locator.CLASS_NAME, "inline-link ")).perform(DriverAtoms.webClick())
}

fun modalContent(expectedText: String) {
Expand All @@ -174,20 +171,20 @@ fun modalContent(expectedText: String) {

fun typeCalculatorAmount(amount: String) {
onWebView(withId(R.id.ModalWebView))
.withElement(DriverAtoms.findElement(Locator.CSS_SELECTOR, ".input ")) // Change to your input box selector
.withElement(DriverAtoms.findElement(Locator.CSS_SELECTOR, ".input "))
.perform(DriverAtoms.webKeys(amount))
}

fun clearCalculatorAmount() {
onWebView(withId(R.id.ModalWebView))
.withElement(DriverAtoms.findElement(Locator.CSS_SELECTOR, ".input ")) // Change to your input box selector
.withElement(DriverAtoms.findElement(Locator.CSS_SELECTOR, ".input "))
.perform(DriverAtoms.clearElement())
}

fun clickApplyNow() {
onWebView(withId(R.id.ModalWebView))
.withElement(DriverAtoms.findElement(Locator.CSS_SELECTOR, "button.button")) // Change to your input box selector
.perform(DriverAtoms.webClick())
onWebView(
withId(R.id.ModalWebView),
).withElement(DriverAtoms.findElement(Locator.CLASS_NAME, ".button.content__row")).perform(DriverAtoms.webClick())
}

fun checkPi4ModalContent() {
Expand Down

0 comments on commit eff4d19

Please sign in to comment.