简体   繁体   中英

How to get a specific value from column & insert it in field, when using selenium webdriver

I am working in selenium web driver & stuck in a scenario. I have to get login code from column & save it in a variable The text in column "message _generated" is

"Dear Adnan, Your passcode is 7856, Please use this password & don't share this with anyone"

I want to pick the code "7856", & save it in a variable. Need help. I am using Java Web Driver. Please note that DB connections & all other stuff are working fine.

Below code assign the passcode from your message to messageCode variable. It's only example how to retrieve this code from text. I hope you know how to get text from that "message_generated" column because without any details noone helps you

String message = "Dear Adnan, Your passcode is 7856, Please use this password & don't share this with anyone";
String template = "Your passcode is ";
String messageCode = message.substring(message.indexOf(template) + template.length(), message.indexOf(',', message.indexOf(template) + template.length()));
System.out.println(messageCode);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM