webdriver - Check for email id in a text in java -


i using java write appium test script & want compare 2 emails, before comparison have fetch email id text splitting string. ex: have text in application "your account email associated pankaj@gmail.com" want split & capture email id text & compare other email id showing in text box. how can ?? doing this:

webelement email_id= driver.findelement(by.xpath("//uiaapplication[1]/uiawindow[1]/uiatextfield[1]"));  string edit_email=email_id.gettext();  system.out.println(edit_email); 

but getting full text.how can split it.

you should try regular expression using java.util.regex.pattern , java.util.regex.matcher. have prepared snippet finds email ids given chunk of text.

    string text = "your account email associated pankaj@gmail.com , has emailed someone@gmail.com.";     pattern pattern = pattern.compile("[\\w]+[\\d\\w]*(@)[\\w]+[\\w\\d]*(\\.)[\\w]+");     matcher matcher = pattern.matcher(text);     while(matcher.find()){         system.out.println(matcher.group());     } 

this should help.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -