I have below table where I am reading entire row if it matches the mobile number "00955555555555" and need to get the code "89721".
table border="2" cellspacing="0" width="100%" cellpadding="0">
Mobile Number Date Message
<td align="left" nowrap><font face="times new roman" size=3 > 00955555555555</font></td>
<td align="left" nowrap><font face="times new roman" size=3 > 2017-04-17 17:34:06.72</font></td>
<td align="left"><font face="times new roman" size=3 > Your authentication code is 89721 to add name as beneficiary for payment from your account. If you have not requested to add this beneficiary, please contact the bank
IMMEDIATELY on 00971 600 54 0000.
<td align="left" nowrap><font face="times new roman" size=3 > 955111111111</font></td>
<td align="left" nowrap><font face="times new roman" size=3 > 2017-04-17 17:31:13.893</font></td>
<td align="left"><font face="times new roman" size=3 > Your authentication code is: 91518. Please do not share this code with any person.</font></td>
<tr>
I have tried below code but it returns the mobile number but not the five digit code.
Code :
public String entire_row_is_read_which_matches_with_the_Mobile_number() throws Throwable {
String mobilenumber="00955555555555";
//Date validate = null;
{
List<WebElement> rows = driver1.findElements(By.cssSelector("tr"));
for (WebElement row : rows)
{
String text = row.getText();
if (text.contains(mobilenumber))
{
String regex = " (\\d+)"; //Your authentication code is
System.out.println(regex);
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(text);
if (matcher.find())
{
valueis = matcher.group(1);
System.out.println(valueis);
break;
}