gpt4 book ai didi

java - 登录gmail打开消息检查消息是否成功

转载 作者:行者123 更新时间:2023-12-01 18:29:19 26 4
gpt4 key购买 nike

Java Selenium program Login to Gmail account in search box check for text this is working fine. How to check if the message is a success or fail If I write a separate class im getting session ID null exception.

//SAP to Magento stock sync

    WebElement searchbox = driver.findElement(By.xpath("//input[@placeholder='Search mail']"));
Thread.sleep(100);
searchbox.click();
searchbox.sendKeys("SAP to Magento stock sync");
Thread.sleep(100);
searchbox.sendKeys(Keys.ENTER);
Thread.sleep(1000);
new WebDriverWait(driver, 30).until(ExpectedConditions
.visibilityOfElementLocated(By.className("xY a4W")));
WebElement NumberofRecord = driver.findElement(By.className("xY a4W"));
System.out.println(NumberofRecord.getText());

错误:

TimeoutException: Expected condition failed: waiting for visibility of element located by By.className: xY a4W (tried for 30 second(s) with 500 milliseconds interval)
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:81)

最佳答案

// extract notification subjects
ArrayList<WebElement> notificationsSubjects = ...// code to locate displayed subjects
// resolve subjects
for (WebElement element: notificationsSubjects) {
if (element.getText().split(": SAP")[0] == "SUCCESS") {
// do something
}
else if (element.getText().split(": SAP")[0] == "ERROR") {
// do something else
}
else {
System.out.print("Unexpected subject.");
}

关于java - 登录gmail打开消息检查消息是否成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60187979/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com