2015-07-06 25 views
-1
<div class="mailview" style="margin-right:18px;"> 

    Dear Customer,<br><br> 
    Greetings from Calling Cards!.<br><br> 

    We've created a new Calling Cards account for you. 
    <br><br> 
    Your Authentication Code is: 125412 <br><br> 
    Click the following link and enter the authentication code to activate your Account: <a href="http://domain.com/Account/CustomerActivation/bedehhhh9ab7-b016h6hf0-4h6h68bf-a9hhh68-5dbd4hh3e77d7d"> Click 

    Here </a>. 

    <br> 
    <br> 

    Please contact us if you have any questions or need further assistance. 

    <br><br>Thank you for your business with us!<br> 




      </div> 

在此我想驗證碼,這是我當點擊鏈接(點擊這裏),將能夠發送代碼到文本框上的另一個窗口,如何獲得價值弗朗mailview webdriver的

有可能,如果是的話,代碼將被讚賞最多。

感謝Advace !!!

+0

後你已經嘗試了什麼。 –

+0

感謝您的快速響應,我無法弄清楚如何繼續... –

回答

0

Java代碼是

WebElement element = driver.findElement(By.xpath("//div[@class='mailview']")); 
    Pattern codePattern = Pattern.compile("(.*)(Your Authentication Code is:)(\\d+)(.*)", Pattern.DOTALL | Pattern.MULTILINE); 
    Matcher m = codePattern.matcher(element.getText()); 
    if (m.matches()) { 
     String code = m.group(3); 
     System.out.println(code); 
    } 
+0

感謝您的回覆,但我收到錯誤, –

+0

您得到了什麼錯誤@YouthIndia – Madhan

+0

無法找到元素:{「method 「:」xpath「,」selector「:」// div [@ class ='mailview']「} –