Skip to content

Can't capture alert ,which is tiggered by the key word "Execute Javascript" #35

@lucasliu

Description

@lucasliu

You can captrue alert which is triggered by some event,bu you can't get it when triggered by "Execute Javascript"

the RF scripts is as follow:

*** Settings ***
Library Selenium2Library

*** Test Cases ***
alerttest
open browser http://localhost:7272 ie
click button button
Alert Should Be Present Hello!

AlertTriggeredbyJavascript
sleep 1s
execute javascript window.f()
Alert Should Be Present Hello!


and the second test case failed!

+KEYWORD: BuiltIn.Sleep 1s
Documentation: Pauses the test executed for the given time.
Start / End / Elapsed: 20120222 10:21:50.109 / 20120222 10:21:51.109 / 00:00:01.000

+KEYWORD: Selenium2Library.Execute Javascript window.f()
Documentation: Executes the given JavaScript code.
Start / End / Elapsed: 20120222 10:21:51.109 / 20120222 10:21:53.375 / 00:00:02.266

-+
KEYWORD: Selenium2Library.Alert Should Be Present Hello!
Documentation: Verifies an alert is present and dismisses it.

Start / End / Elapsed: 20120222 10:21:53.375 / 20120222 10:21:55.046 / 00:00:01.671

+KEYWORD: Selenium2Library.Capture Page Screenshot
Documentation: Takes a screenshot of the current page and embeds it into the log.
Start / End / Elapsed: 20120222 10:21:53.390 / 20120222 10:21:54.281 / 00:00:00.891

+KEYWORD: Selenium2Library.Capture Page Screenshot
Documentation: Takes a screenshot of the current page and embeds it into the log.
Start / End / Elapsed: 20120222 10:21:54.281 / 20120222 10:21:55.046 / 00:00:00.765
10:21:55.046 INFO

10:21:55.046 FAIL There were no alerts

IS there any difference between the tow way?

Here is the HTML under testing :
[input type="submit" name="button" id="button" value="提交" onclick="f()" /]
[script type="text/javascript"]
function f()
{
alert("Hello!")
}
</script>
[/html]


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions