Hi @walpokbymon,
There’s not a whole lot to show in a video, but I can try to explain it step by step:
-
Record a test using the Record Mobile feature of Katalon Studio (you have probably already done this). You will probably not be able to record the toast message - we’ll put that in later.
-
Once you’ve finished recording your test, open your new test case file
-
Click the tab at the bottom of the test case for “Script” - you’ll see the code for the test
-
At the top of the test file, copy and paste the following lines:
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory import io.appium.java_client.AppiumDriver import com.kms.katalon.core.util.KeywordUtil
-
Find the spot in the test code right after you perform the action that triggers the toast.
-
Copy and paste the following lines after the action that triggers the toast:
AppiumDriver<?> driver = MobileDriverFactory.getDriver() def toast = driver.findElementByXPath("//android.widget.Toast[@text='Added to cart']") println("Toast element: " + toast) if (toast == null) { KeywordUtil.markFailed('ERROR: Toast object not found!') }
-
Change the
'Added to cart'
text to whatever the text of your toast should say. -
Save the test file
-
Run your test
-
Look at the “Console” tab of the test for the text “Toast element”
-
If all goes well, your tests will pass. If for some reason the toast cannot be found, the test will fail when detecting it.
Hope this helps,
Chris