【发布时间】:2022-08-23 13:54:47
【问题描述】:
我面临的错误internal.qaauto.framework.exceptions.EmailDriverException:javax.mail.AuthenticationFailedException:[AUTHENTICATIONFAILED] 无效凭据(失败)
at internal.qaauto.framework.drivers.email.ImapsEmailDriver.connect(ImapsEmailDriver.java:55)
at certainwebapptests.CreateSubAccount.setUp(CreateSubAccount.java:53)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:178)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:782)
at org.testng.TestRunner.run(TestRunner.java:632)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
at org.testng.TestNG.run(TestNG.java:1064)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)
引起:javax.mail.AuthenticationFailedException:[AUTHENTICATIONFAILED] 无效凭据(失败) 在 com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:661) 在 javax.mail.Service.connect(Service.java:295) 在 internal.qaauto.framework.drivers.email.ImapsEmailDriver.connect(ImapsEmailDriver.java:45) ... 24 更多
这是我的代码尝试 { 属性 connectionProperties = new Properties();
// Set IMAPS as store protocol
connectionProperties.put(\"mail.store.protocol\", \"imaps\");
connectionProperties.put(\"mail.imaps.ssl.checkserveridentity\", \"false\");
// Create a session with mail server
session = Session.getDefaultInstance(connectionProperties);
// Get the Store, which is JavaMail name for the entity that holds the mails.
store = session.getStore(\"imaps\");
// Connect the recently created Store
reporter.debug(\"Connecting to \" + MAIL_HOSTNAME + \":\" + IMAP_PORT + \" using \" + MAIL_USER + \"/\" + MAIL_PASSWORD);
store.connect(MAIL_HOSTNAME, IMAP_PORT, MAIL_USER, MAIL_PASSWORD);
// Check that connection was successful
checkConnection();
// Select Inbox folder
selectFolder(\"Inbox\");
} catch (MessagingException e) {
reporter.error(\"Unable to connect to mail server \" + MAIL_HOSTNAME + \" through port \" + IMAP_PORT + \". Using \"
+ MAIL_USER + \"/\" + MAIL_PASSWORD + \". Reason: \" + e.getMessage());
throw new RuntimeException(e);
}
标签: java email selenium-webdriver gmail-imap