如何解决WebDriver异常:消息:超时

时间:2018-08-22 08:17:41

标签: robotframework

我不断收到WebDriver异常:消息:每次运行脚本时超时。我有python版本2.7.14,robotframework版本3.0.4和硒库版本3.1.1。我希望有人能帮助我。

下面是我正在处理的代码。

tricontourf

下面是我得到的日志。

*** Keywords ***
Go to Google
    Open Browser  https://google.com  Firefox
    Maximize Browser Window

3 个答案:

答案 0 :(得分:0)

The solution depends on why the timeouts happen. If they happen because your website is slow, you need to either speed up the web server or increase the timeout.

Another reason could be that you are waiting for something that will never come. For example, you might have a typographical error in an id or xpath.

We can't give a specific answer since timeouts can happen for many reasons. You will need to look at the actual timeout message and the keyword that caused it, and figure out the root cause. Once you understand the root cause (typo, slow server, etc), you will probably be able to figure out the solution.

答案 1 :(得分:0)

要解决此问题,我从https://www.seleniumhq.org/download/下载了Chrome驱动程序。然后,将这一行添加到我的代码中。

创建Webdriver Chrome可执行文件= C:\ Python27 \ chromedriver.exe

我的关键字现在如下所示。

<script type="text/javascript">
$(function () {
    $("#upload").bind("click", function () {
        if (typeof ($("#fileUpload")[0].files) != "undefined") {
            var files = $("#fileUpload")[0].files;
            $.each(files, function (index,file) {
                var size = parseFloat(file.size / (1024 * 1024)).toFixed(2);
                if (size < 5.00) {
                    alert("You are eligible to upload file");
                }
                else {
                    alert("This File is too large");
                }
            });
        } else {
            alert("This browser does not support HTML5.");
        }
    });
});
</script>

答案 2 :(得分:0)

  1. 安装Firefox驱动程序https://www.seleniumhq.org/download/
  2. 将驱动程序添加到计算机上的环境变量

enter image description here

enter image description here 3.您现在可以运行测试

Go to Google 
    Open Browser  https://google.com  Firefox
    Maximize Browser Window