我们的一些网页有第三方分析运行在后端。在我看来,selenium正在等待这些过程完成,然后再进入下一步。问题是它大约需要5-6分钟。有什么办法让我们坐上这个等待,然后继续下一步吗?
我试着用JavaScript单击按钮(该按钮可以将用户带到具有某些后端进程的页面),但随后它就被卡住了。
谢谢。
发布于 2014-02-23 04:41:51
在webdriver上单击页面加载上的元素甚至是可能的;默认情况下,webdriver会等待整个页面加载,然后选择元素。链接和文本是可见的,但它们是不可点击的;但是,它在Selenium上很好地工作,在页面加载时选择元素。
Webdriver利用FirefoxProfile来避免这种风险;它只适用于火狐浏览器。
FirefoxProfile fp = new FirefoxProfile();
fp.setPreference("webdriver.load.strategy", "unstable");
driver = new FirefoxDriver(fp);发布于 2014-02-23 12:01:44
我建议你可以利用代理。布朗瑟波与selenium集成得很好,非常容易使用:
// start the proxy
ProxyServer server = new ProxyServer(4444);
server.start();
// get the Selenium proxy object
Proxy proxy = server.seleniumProxy();
// This line will automatically return http.200 for any request going to google analytics
server.blacklistRequests("https?://.*\\.google-analytics\\.com/.*", 200);
// configure it as a desired capability
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, proxy);
// start the browser up
WebDriver driver = new FirefoxDriver(capabilities);编辑:我刚刚发现,在硒2.40中,pageLoading策略是实现的。
partial interface WebDriver {
const DOMString CONSERVATIVE = 'conservative';
const DOMString NORMAL = 'normal';
const DOMString EAGER = 'eager';
const DOMString NONE = 'none';
};https://stackoverflow.com/questions/21962701
复制相似问题