- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Selenium 的新手,似乎遇到了第一个障碍。虽然我可以在 Firefox 中非常愉快地关闭浏览器窗口,但在 IE 中却无法正常工作。
请参阅下面的示例测试,每次运行时都会留下一个打开的 IE 窗口:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
namespace TestingTesting123
{
[TestClass]
public class About
{
IWebDriver _ieDriver;
IWebDriver _ffDriver;
[TestInitialize]
public void Startup()
{
_ffDriver = new FirefoxDriver(); // Closes
_ieDriver = new InternetExplorerDriver(); // Doesn't
}
[TestMethod]
public void Go_to_bbc()
{
_ffDriver.Url = "http://news.bbc.co.uk";
_ieDriver.Url = "http://news.bbc.co.uk";
}
[TestCleanup]
public void Cleanup()
{
_ffDriver.Quit();
_ieDriver.Quit();
}
}
}
报告了类似的问题here对于 Java - 我似乎有同样的问题,但 C#。
我在 Windows 8.1 上使用 IE 11。我可以通过这样做来解决这个问题:
using System.Diagnostics;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
namespace TestingTesting123Workaround
{
[TestClass]
public class About
{
IWebDriver _ieDriver;
IWebDriver _ffDriver;
int[] _startupIEProcessIds;
[TestInitialize]
public void Startup()
{
_startupIEProcessIds = Process.GetProcessesByName("iexplore")
.Select(x => x.Id).ToArray();
_ffDriver = new FirefoxDriver();
_ieDriver = new InternetExplorerDriver();
}
[TestMethod]
public void Go_to_bbc()
{
_ffDriver.Url = "http://news.bbc.co.uk";
_ieDriver.Url = "http://news.bbc.co.uk";
}
[TestCleanup]
public void Cleanup()
{
_ffDriver.Quit();
_ieDriver.Quit();
foreach (var ieDriver in Process.GetProcessesByName("IEDriverServer"))
ieDriver.Kill();
foreach (var ie in Process.GetProcessesByName("iexplore")
.Where(x => !_startupIEProcessIds.Contains(x.Id)))
ie.Kill(); // Typing that was oddly therapeutic
}
}
}
但是,这似乎非常繁琐,不是最佳实践。有什么想法吗?
最佳答案
您可能想试一试,因为退出/关闭应该有效。 可能是 IE 当前有一个错误,稍后会修复,但与此同时这可能会有所帮助。我过去在 chrome 驱动程序和 firefox 上遇到过类似的问题。
关于c# - IE 11 - webdriver.Quit() 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28697568/
可以说我只是使用 pygame 有一个正常的游戏循环。 run = True while run: for event in pygame.event.get(): if ev
如何让控制台应用程序运行直到用户输入“Q”、“q”、“Quit”或“quit”来终止它? 这是我当前的代码: public class Class1 { [STAThread] static
我正在创建一个基于 promise 的 API。如果我一次发出一个请求,一切都会正常,但是,如果 2 个或更多请求在一秒内到达服务器,我会收到以下错误 Error: Cannot enqueue Qu
考虑: (gdb) q A debugging session is active. Inferior 1 [process 9018] will be killed. Quit an
我有以下设置: int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); // Create the DBM
我的停靠菜单总是自动添加“退出”和其他 2 个菜单项,我如何阻止/修改它们? 更新: 确实没有办法删除/阻止/重定向“退出”菜单项。最后像打击一样使用了彼得的推荐希望对其他人有帮助 -(NSAppli
这是我的代码:1. 用户输入两个名称,中间有一个空格。这意味着需要读取两个字符串。 IE。输入: 约翰·多伊。 然后在字符数组中检查字符串。 (工作正常)。 while 循环一直持续到用户输入“sto
刚刚弄乱了 pygame 并遇到了这个错误。 代码: import sys import pygame pygame.init() size = width, height = 600, 400 sc
看完Eric Lippert’s answer我的印象是 await和 call/cc几乎是同一枚硬币的两面,最多只是句法上的差异。然而,在尝试实际实现时 call/cc在 C# 5 中,我遇到了一个
Memcached quit 命令用户关闭一个客户端连接 语法 quit 范例 连接到127.0.0.1 上 11211 的 Memcached 服务, 然后退出 $ telnet 12
这只是一种方便,但我认为很有用。请注意,IPython 和 Matlab 一样允许纯退出。因此,在 Julia 中允许混叠是合理的。 感谢您提供有关如何执行此操作的任何想法。 最佳答案 退出 Juli
我正在运行Django服务,该服务将启动chromedriver用于 Selenium ,并爬取网站以获取数据。 另一个Java服务通过HTTP调用Django服务。 这是代码: views.py p
Iam在我的游戏中一起使用Adcolony和Vungle时,一切正常,但是当用Application.Quit()游戏退出游戏时,关闭了游戏,但弹出了文本“不幸的应用程序崩溃”的弹出窗口。 在这里我附
我最近做了一个小游戏,然后用pyinstaller把它变成了一个应用程序。运行时,有两种关闭方式。它是全屏的,因此不包括单击红色 x 按钮,但基本上我有这个 if keys[pygame.K_ESCA
我正在练习使用递归,但有些东西我不太明白。例如,我写了这个简单的倒计时函数,它应该等到一秒过去,然后倒计时到下一秒。 我首先是这样写的: function countdown(sec) { con
我正在使用 Appium 安装应用程序。安装后,应用程序应该在后台运行。另一项测试应使用 Chrome 在应用程序在后台运行时检查互联网连接。问题是 driver.quit() 甚至启动 Androi
我有一个正在运行测试的框架;任何错误都会导致 WebDriver 实例调用类似 handleException 方法的方法,我在其中调用 driver.quit() 方法。我觉得 driver.qui
我知道所有基本的处理程序,即 on run、on open 和 onreopen。但是这个处理程序,on quit,让我很困惑。我的问题是,它的用途是什么以及它是如何触发的? 最佳答案 on quit
我有两个 for 循环: for event in pygame.event.get(): if event.type == QUIT:
我目前正在编写一个小的 GUI 程序,它可以完成一些工作并在之后退出。工作完成后,GUI 线程会更新用户的信息。 这是我目前使用的模式,我认为它不是最优雅的模式: static void MainFo
我是一名优秀的程序员,十分优秀!