您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

预期条件失败:正在等待By.xpath定位的元素的可见性

预期条件失败:正在等待By.xpath定位的元素的可见性

请尝试以下操作:

package PageObjects;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.webdriverwait;

public class SignIn {

    private static WebElement element = null;
    public static WebElement SignIn_click(WebDriver driver) throws InterruptedException {
    element = driver.findElement(By.xpath("id('J_SC_header')/header/div[2]//span[1]/a[@data-val='ma_signin']"));

    while (!isDisplayed(element)) 
    {
        Thread.sleep(3000);
        System.out.println("Element is not visible yet");
    }
    return element;

    }
    public static boolean isDisplayed(WebElement element) {
        try {
            if(element.isDisplayed())
                return element.isDisplayed();
            }catch (NoSuchElementException ex) {
            return false;
        }
        return false;
    }
}
其他 2022/1/1 18:16:23 有716人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶