Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
关于问题org.openqa.selenium.unhandleAlertException:存在模态对话框:此页面上的脚本可能正忙_Selenium_Selenium Webdriver_Webdriver - Fatal编程技术网

关于问题org.openqa.selenium.unhandleAlertException:存在模态对话框:此页面上的脚本可能正忙

关于问题org.openqa.selenium.unhandleAlertException:存在模态对话框:此页面上的脚本可能正忙,selenium,selenium-webdriver,webdriver,Selenium,Selenium Webdriver,Webdriver,我目前正在为firefox版本2.46.0使用JavaWebDriver 2.53.1。在长时间运行脚本时,我遇到以下错误。因为我有不同的配置文件,可以使用同一个浏览器同时运行多个脚本。这个firefox浏览器似乎崩溃了 请查看以下错误详细信息 org.openqa.selenium.UnhandledAlertException: Modal dialog present: A script on this page may be busy, or it may have stopped re

我目前正在为firefox版本2.46.0使用JavaWebDriver 2.53.1。在长时间运行脚本时,我遇到以下错误。因为我有不同的配置文件,可以使用同一个浏览器同时运行多个脚本。这个firefox浏览器似乎崩溃了

请查看以下错误详细信息

org.openqa.selenium.UnhandledAlertException: Modal dialog present: A script on this page may be busy, or it may have stopped responding. You can stop the script now, open the script in the debugger, or let the script continue.

Script: https://website/js/jq…596b2b8fa35fe3a634ea342d7c3.js:1
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'MACHINE NAME', ip: 'Ip address', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=47.0.2, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 39cfd1aa-1d74-4b18-bdcd-5255a2b90127
    at sun.reflect.GeneratedConstructorAccessor51.newInstance(Unknown Source)
我还应用了两种解决方案 说 1.

  • 按照下面的链接
  • 但这些问题似乎并没有固定在mt脚本上


    有人能提供解决方案吗?

    根据我的经验,只有在您尝试进行页面导航但尚未处理屏幕警报时才会引发此错误。您需要使用
    IAlert
    类接受或解除此警报才能继续

    首先查找触发警报的命令,然后处理警报

    如果您详细说明您的问题,我可能能够提供更多帮助,如果您包含导致此异常的selenium代码,这将非常有用

    下面是我用来处理警报的一些函数

    public void AcceptAlert()
    {
        try
        {
            WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(30));
            wait.Until(ExpectedConditions.AlertIsPresent());
            IAlert alert = Driver.SwitchTo().Alert();
            alert.Accept();
        }
        catch (Exception)
        { }
    }
    public void DismissAlert()
    {
        try
        {
            WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(30));
            wait.Until(ExpectedConditions.AlertIsPresent());
            IAlert alert = Driver.SwitchTo().Alert();
            alert.Dismiss();
        }
        catch (Exception ex)
        {
            log.Debug(ex.Message);
        }
    }
    

    没有获取此错误的特定函数。我基本上是在文本框中输入文本,我得到了这个错误。现在还有一件事,我在同一台机器上有两个不同的存储库,它们具有不同的配置文件。我使用相同的firefox浏览器(相同的安装路径)测试所有脚本。我可能一次做两次测试。这是否造成了问题?谢谢你的代码,不管怎样,我是否可以使用所有函数都通用的代码,比如说,如果驱动程序出现我提到的错误,那么它应该通过你的代码来解决这个问题?请开导我
    public void AcceptAlert()
    {
        try
        {
            WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(30));
            wait.Until(ExpectedConditions.AlertIsPresent());
            IAlert alert = Driver.SwitchTo().Alert();
            alert.Accept();
        }
        catch (Exception)
        { }
    }
    public void DismissAlert()
    {
        try
        {
            WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(30));
            wait.Until(ExpectedConditions.AlertIsPresent());
            IAlert alert = Driver.SwitchTo().Alert();
            alert.Dismiss();
        }
        catch (Exception ex)
        {
            log.Debug(ex.Message);
        }
    }