【问题标题】:[76.508][SEVERE]: Unable to receive message from renderer (in console)[76.508][严重]:无法从渲染器接收消息(在控制台中)
【发布时间】:2017-06-27 20:39:35
【问题描述】:

需要我的问题的答案。

在我的测试脚本中,我试图接受警报,然后表格应该在接受警报后加载,但同样的事情没有发生。由于表格未加载,我收到以下错误:-

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//table[contains(@id,'Content_gvSelectSeats')]/tbody "} (会话信息:chrome=58.0.3029.110)

这是同步问题吗??

下面的一段代码:-

1) 点击获取 reallocate.getReallocateclickFetch(); // 简单点击按钮

2) 现在微调器将移动并且警报来了 // 等待警报并接受它

 public boolean WaitUntilAlertLoad()
        {
             boolean foundAlert = false;
            WebDriverWait wait = new WebDriverWait(driver, 30 /*timeout in seconds*/);
            do {


                for(int i=0;i<100;i++)
                {   

                    try {
                        wait.until(ExpectedConditions.alertIsPresent());
                        foundAlert = true;
                        driver.switchTo().alert().accept();
                    } catch (Exception e) {
                        foundAlert = false;
                    }
                    if(i==99)
                    {
                        break;
                    }
                }

            }while(foundAlert=false);
            return foundAlert;
        } 

但是在接受警报表之后仍然没有加载。我该怎么办??

【问题讨论】:

    标签: selenium


    【解决方案1】:

    这是您问题的答案:

    在切换到AlertAcceptDismiss 之前,请考虑将父窗口的windowHandle 存储在一个字符串中,如下所示:

    //Stores the parent window handle
    String windowHandle = driver.getWindowHandle();
    

    现在,您可以将Alert 切换为AcceptDismiss,如下所示:

    //Perform your actions on the Alert by switching over
    driver.switchTo().alert().accept();
    

    一旦你完成了带有警报的操作,考虑通过存储在字符串中的父窗口的 windowHandle 切换回父/主窗口,如下所示:

    //Switch back to the parent window
    driver.switchTo().window(windowHandle );
    

    如果这能回答您的问题,请告诉我。

    【讨论】:

    • 不,它没有帮助:(
    • 您能否考虑使用您最近的代码以及所做的更改来更新问题并粘贴错误堆栈跟踪以进行进一步分析?谢谢
    猜你喜欢
    • 1970-01-01
    • 2018-02-14
    • 1970-01-01
    • 2021-11-05
    • 2019-01-31
    • 2020-04-25
    • 2020-07-26
    • 2019-09-09
    • 1970-01-01
    相关资源
    最近更新 更多