Selenium Force关闭Firefox [英] Selenium Force Close Firefox

查看:139
本文介绍了Selenium Force关闭Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    ProfilesIni profile = new ProfilesIni();
    FirefoxProfile ff = profile.getProfile("ScreenCapture");
    WebDriver driver = new FirefoxDriver(ff);
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
    driver.get(url);

    Thread.sleep(8000);

    File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

    driver.quit();

driver.manage().timeouts().implicitlyWait(15,TimeUnit.SECONDS); 是否应该在15秒后强制关闭由硒生成的Firefox浏览器?浏览器只是坐着,说要传送一个小时以上的数据.基本上只是挂着说它的转移...

Shouldn't driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); force a close of the selenium generated Firefox browser after 15 seconds? The browser just sits and says its transferring data for an hour+. Basically just hangs saying its transferring...

我正在捕获ajax繁重的页面,这就是为什么Im要求所有内容在页面加载后等待8秒.但这与驱动程序在15秒后强制关闭无关.

I am capturing ajax heavy pages which is why Im asking everything to wait for 8 seconds after page loads. But that should have nothing to do with the driver forcing a close after 15 seconds.

我要去哪里错了?

详细信息:截至10分钟前,带有Firefox 10.0.12和最新Selenium的Centos x64 6.4.

Details: Centos x64 6.4 with Firefox 10.0.12 and latest Selenium as of 10 min ago.

我可以用Java做些什么来解决这个问题吗?

Is there something I can do in Java to go around this?

问题:N秒后如何强制关闭由Selenium生成的Firefox窗口?

推荐答案

我的linux知识有限,但是您可以通过运行linux命令

My linux knowledge is limited, but you can kill a process by running the linux command pkill.

driver.quit();
Thread.sleep(15000); //use a poll loop instead to check process running every 1 sec 
Runtime rt = Runtime.getRuntime();
rt.exec("pkill firefox"); 

我认为Java进程需要具有足够的权限才能杀死某个进程,但尚未尝试过.

I think that the java process will need to have enough permissions to kill a process, but haven't tried it.

这篇关于Selenium Force关闭Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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