【问题标题】:Problems with Error: There was an unexpected Confirmation!错误问题:出现意外的确认!
【发布时间】:2011-01-06 09:29:55
【问题描述】:

我正在尝试从表中删除用户。起初我遇到超时错误,但使用了 BeatnicClick(),如下所述:

Selenium IDE click() timeout

这解决了超时错误,但我仍然收到意外的确认错误。以下是部分源代码:

selenium.Click("ctl00_btnAddressBook"); selenium.WaitForPageToLoad("30000");

// selenium.BeatnicClick("ctl00_page_content_ExistingEmployees_ctl03_btnDeleteEmployee");

String 你确定要删除吗 选定的项目? = selenium.GetConfirmation();

任何帮助将不胜感激。提前致谢。

【问题讨论】:

    标签: ide selenium selenium-ide confirmation


    【解决方案1】:

    要处理确认,您的代码应如下所示

    selenium.Click("ctl00_btnAddressBook"); 
    selenium.WaitForPageToLoad("30000");
    //the IDE code is to get around the IDE bug that it waits on click but it works in Se:RC
    selenium.Click("ctl00_page_content_ExistingEmployees_ctl03_btnDeleteEmployee");
    //handle the confirmation that appears after the click
    string confirmMessage = selenium.GetConfirmation();
    //Assert its the correct message
    Assert.IsTrue(Regex.IsMatch(confirmMessage,"Are you sure you want to delete the selected item?"));
    

    这应该点击删除元素,然后得到确认,如果你想要它可以断言它的正确消息

    【讨论】:

    • 我不明白你的问题。我以为你需要 Selenium RC 方面的帮助。您需要 RC 或 IDE 方面的帮助吗?
    • 我最初使用的是 IDE,但我已切换到 Selenium RC。我在另一个区域尝试了您的建议,但仍然收到错误消息。我在下面的答案中发布了代码(因为它不适合这里)
    • 如果您使用的是IDE,则需要在后续命令之前进行storeConfirmation。如this question 的回答中所述
    猜你喜欢
    • 1970-01-01
    • 2015-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-21
    相关资源
    最近更新 更多