Is there a way to use the Keyboard to close tabs?
My problem is this - if I allow popups - whenever I try to close them,
firefox crashes and this appears in the event log:
Faulting application name: Firefox.exe, version: 7.0.1.4288, time
stamp: 0x4e83b93a
Faulting module name: xul.dll, version: 7.0.1.4288, time stamp:
0x4e83b840
Exception code: 0xc0000005
Fault offset: 0x000b8acc
So I switched to using tabs - I force firefox to open tabs instead of
popups - that prevents the crashes, but it is impossible to close the
tabs with Browser.Close(); like it was with popups.
But since I'm not recreating the firefox instance after each run - it
fills up with useless tabs.
I tried doing this after each run, but it doesn't work
var keyb = Browser.Keyboard;
for (var i = 0; i < 5; i++ )
{
try
{
Browser.SwitchTo().ActiveElement();
keyb.PressKey(Keys.Control);
keyb.SendKeys("w");
keyb.ReleaseKey(Keys.Control);
}
catch (Exception){}
}
Is there any way to close tabs or closing popups without crashing?
Closing popups used to work when I just started with webdriver (maybe
9 months ago), but it broke at some point and never worked since.
Any tips? Thank you
new
Actions(Browser).KeyDown(Keys.Control).SendKeys("w").KeyUp(Keys.Control).Perform();
--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
I'd really love to see this solved from the webdriver side - I'll try
to make a simple page that exhibits this behavior.
var profile = new FirefoxProfile();
//Allow popups to be opened during page-load
profile.SetPreference("dom.disable_open_during_load", false);
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://jsfiddle.net/VftEX/1/");
Thread.Sleep(1000);
var windows = driver.WindowHandles.ToList();
windows.RemoveAt(0);
foreach (var win in windows)
{
driver.SwitchTo().Window(win);
driver.Close();
}
Thread.Sleep(100);
driver.SwitchTo().DefaultContent();
On Dec 3, 5:50 pm, Danny Guerrier <dguerr...@gmail.com> wrote:
> How trying the get default content after ensuring the popup is closed?
> Instead of the timeout, wait until the window is one less the previous
> before doing the get default content. I suspect a race condition.
>