Navigate to the link in the email during mobile testing

Hi everyone. I have such case:
1.User sign up on mobile application. (no browser app)
2.Has to click on activation link in the email

For getting email and email body content I am using Gmail Plugin for Katalon.
Somehow I substring the link from the letter. But how can I click it now ?

@Vlada_Aleksandrova, please read this post:

So, there is a code where I get message and find a link. How can I click it?

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

String emailc = CustomKeywords.‘com.testwithhari.katalon.plugins.Gmail.readLatestEMailBodyContent’(‘testa@gmail.com’,
‘passq’, ‘Inbox’)

printf(emailc)
def link = emailc.findAll(/http://\s+/)

idk about clicking a link from an email, that is retrieved programmatically with no UI involved, but here’s how you can retrieve it, assuming that your Gmail.readLatestEMailBodyContent() call returns HTML string.

From there, you’ll have to log out your HTML message string, pretty print it, and from there, you can use your web-testing skills to create some xpath selector string for the actual link.

Then, you use my code like:

WebUI.navigateToUrl(Gmail.readLatestEMailBodyContent’(‘testa@gmail.com’,
‘passq’, ‘Inbox’), "${yourLinkXPath}/@href");

To be fair, email messages can take some time to hit inboxes. Hence you might also want to have some retry logic in place. Here is example from my real project code base:

import java.util.concurrent.TimeUnit
// ...rest of imports

public final class EmailUtils { 

	//...rest of code base

	public static String ExtractSignUpLink() {
		String link;

		int retryAttempts;

		ActionHandler.Handle({
			link = this.ProcessHTML(this.GetLatestMessageBody(30),
					"//a[.//div[@class = 'sign-mail-btn-text']]/@href");
		}, { boolean success, ex ->
			if (success)
				return;
			// handle ex
			if (((GoogleJsonResponseException)ex).getDetails().getCode() >= 400)
				throw ex;
			sleep(1000 * 2**retryAttempts++);
		}, TimeUnit.MINUTES.toSeconds(15))

		return link;
	}

	//...rest of code base
}

public final class ActionHandler {
    public static void Handle(Closure onAction, Closure onDone, long timeOut) {
        long startTime = System.currentTimeSeconds();
        while (System.currentTimeSeconds() < startTime + timeOut) {
            try {
                onDone(true, onAction());
                return;
            } catch (Exception ex) {
                onDone(false, ex);
            }
        }
    }
}