Selenium WebDriver throws Timeout exceptions sporadically

前端 未结 8 1376
感情败类
感情败类 2020-12-01 07:43

Using selenium for ui tests on our project. We are running the newest version 2.30.0. We use Firefox WebDriver and are running Firefox 19.0.

Generally said the ui te

8条回答
  •  自闭症患者
    2020-12-01 08:15

    Happened to me in four different scenarios:

    1. The cause was that the window handle I was querying was already closed or in closing stages. If this is the case, you better check that the window still exist before querying it. If you want to avoid the long timeout period of 60 seconds, you should change the way you create the Firefox instance to decrease the 60 seconds delay:

      new FirefoxDriver("FfBinaryPath", FfProfileInstance, TimeSpan.FromSeconds(5));

    2. The cause was the flash plugin 'Protected Mode'. This scenario happened to me only under windows 7 and 8 when they ran under Jenkins job, the timeout did not happened sporadically. In order to fix it, I ran my Firefox selenium instance with the flash security mode disabled:

      FfProfile.SetPreference("dom.ipc.plugins.flash.disable-protected-mode", true);

    3. Another cause, also non sporadic, under Jenkins and related to Flash, happened when using Firefox version 45. In order to resolve this issue I had to downgrade to version 44 or alteratively uninstall Flash.

    4. Internal browser reason: Sometimes the browser takes more than one minute to react Selenium calls. In such case, setting the browser command timeout above 60 seconds can solve the issue. for example:

      new FirefoxDriver("FfBinaryPath", FfProfileInstance, TimeSpan.FromMinutes(3));

提交回复
热议问题