不要等待页面加载 [英] Do not wait for page to load

查看:108
本文介绍了不要等待页面加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,我必须从中获取数据的站点加载时间太长,这增加了我的测试用例的执行时间. 我不想等待整个网站加载.我能做些什么? 我已经使用了30秒的超时时间,但是即使超出时间也不会引发异常.可能是所有JavaScript都在网页的onload事件中调用了. 减少测试用例的执行时间非常重要,我刚刚开始使用硒,并且没有足够的知识,请帮帮我

My problem is that the site from which I have to fetch data is taking too much time in loading which increases the execution time of my testcase. I don't want to wait for whole site to load. What can I do? I have used timeout of 30 sec but it doesn't throw exception even if time is exceeded. May be all the javascripts are called in the onload event of webpage. It is very important to decrease the execution time of the test case, I have just started working with selenium and don't have thorough knowledge, please help me out

推荐答案

使用FireFox,您可以尝试webdriver.load.strategy =不稳定.也许会适合您.
此处进行检查.

不幸的是,通常webdriver等待整个页面加载.我在测试类似Youku的页面时遇到了类似的问题-有时3分钟还不足以获取内容.

您也可以尝试:
IJavaScriptExecutor js = (IJavaScriptExecutor)Driver; js.ExecuteScript("return window.stop");
它在本地对我有用,尽管在VM上我仍然遇到相同的问题.

Using FireFox you can try webdriver.load.strategy = unstable. Maybe it will suits you.
Check here.

Unfortunately usually webdriver waits for whole page to be loaded. I got similar problem with testing pages like Youku - sometimes 3min it's not enough to get content.

You can also try with:
IJavaScriptExecutor js = (IJavaScriptExecutor)Driver; js.ExecuteScript("return window.stop");
It worked for me locally although on VMs I had still the same problem.

这篇关于不要等待页面加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆