I have a test script that enters a gmail account into a field and requests a verification code. When i try to open gmail to retrieve the verification code i get the error: This browser or app may not be secure.
Is there a way around this?
Hi there, ![]()
Thank you very much for your topic! It may take a little while before Katalon team member or others forum members respond to you.
In the meantime, you can double-check your post to see if you can add any extra information i.e. error logs, HTML codes, screenshots, etc. Check out this posting guide to help us help you better!
Thanks! ![]()
Katalon Community team
Refer to the following:
does it work manually?
Yes it does. I am presuming its because katalon opens it’s own browser version and not locally from my pc if that makes sense
Are running your test case behind corporate proxy?
that page is google detecting the automated browser, and it is deliberate, so the proxy question is a dead end. there is no reliable way to log in to gmail through webdriver any more.
skip the ui and read the code from the mailbox directly. turn on 2 step verification on the test gmail account, create an app password, and read the latest message over imap. javax.mail ships with katalon:
import javax.mail.*
import javax.mail.search.FlagTerm
Properties p = new Properties()
p.put('mail.store.protocol', 'imaps')
Store store = Session.getInstance(p).getStore()
store.connect('imap.gmail.com', 'test.account@gmail.com', GlobalVariable.gmailAppPassword)
Folder inbox = store.getFolder('INBOX'); inbox.open(Folder.READ_ONLY)
Message[] msgs = inbox.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false))
String body = msgs[-1].getContent().toString()
String code = (body =~ /\b\d{6}\b/)[0]
poll that for up to a minute after you request the code, then type it into your app. it is faster than opening gmail anyway and does not break when google changes the login page.
