ullmark
ullmark

Reputation: 2479

Clicking Confirm Dialog Selenium in .NET

I'm trying to make Selenium 2.4.0 Accept a Javascript generated "Confirm-Dialog", using Specflow and Firefox. I'm having trouble finding what I should do in my step below. (Tried to find an equivalent way of doing it in .NET from various Java implementations, but it isn't working)

When I click "Delete" on the App
    And I confirm the warning

Step definition...

[When(@"I confirm the warning")]
public void WhenIConfirmTheWarning()
{
    // WebDriver.Something?
}

Upvotes: 5

Views: 3574

Answers (2)

JimEvans
JimEvans

Reputation: 27486

The way to confirm the alert in the .NET bindings is as follows:

driver.SwitchTo().Alert().Accept();

I have had this working with the Selenium .NET bindings 2.4.0, using Firefox 5.0.

Upvotes: 10

Erik A. Brandstadmoen
Erik A. Brandstadmoen

Reputation: 10588

Are you using Firefox 4.x or above? There seems to be an issue with Firefox 4.x and Selenium: Firefox 4 confirmation dialog in selenium 2.0b3 The suggested solution is to migrate to Selenium/WebDriver.

Upvotes: 0

Related Questions