【问题标题】:How can I do automated tests on non JavaScript applications?如何对非 JavaScript 应用程序进行自动化测试?
【发布时间】:2010-09-17 17:20:47
【问题描述】:

我正在编写与 JavaScript 配合得很好的控件,但即使没有它,它们也必须工作。现在用硒进行测试对我来说很好。但是所有使用禁用 JavaScript(在我的浏览器中)的测试都不会使用 selenium 运行。有没有办法为此目的进行自动化测试?

【问题讨论】:

    标签: javascript testing selenium


    【解决方案1】:

    我不知道 Selenium,但使用 NoScript Firefox 扩展,您可以在每个域的基础上禁用脚本。那么您可以使用它来允许 Selenium 但禁用您页面的脚本吗?

    【讨论】:

    • Selenium 通过使用 Javascript 与网页进行交互来工作。这意味着如果您关闭 Javascript,Selenium 将无法运行。
    【解决方案2】:

    WWW::MechanizeTest::WWW::Mechanize 是两个 Perl 模块,可以做到这一点。

    use Test::More tests => 5;
    use Test::WWW::Mechanize;
    
    my $mech = Test::WWW::Mechanize->new;
    
    # Test you can get http://petdance.com
    $mech->get_ok( "http://petdance.com" );
    
    # Test the <BASE> tag
    $mech->base_is( 'http://petdance.com/', 'Proper <BASE HREF>' );
    
    # Test the <TITLE>
    $mech->title_is( "Invoice Status", "Make sure we're on the invoice page" );
    
    # Test the text of the page contains "Andy Lester"
    $mech->content_contains( "Andy Lester", "My name somewhere" );
    
    # Test that all links on the page succeed.
    $mech->page_links_ok('Check all links');
    

    【讨论】:

      【解决方案3】:

      查看其他自动化软件包,例如 TestCompleteAutoIt

      【讨论】:

        【解决方案4】:

        如果它只是没有 javascript 的纯 html,您可以使用普通的屏幕抓取技术来比较您从服务器下载的 html 与您期望的内容,无需在浏览器中进行测试。

        【讨论】:

          【解决方案5】:

          您可以使用 Watir 来测试您的 Web 应用程序。

          http://wtr.rubyforge.org/

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2021-10-11
            • 1970-01-01
            • 2014-06-27
            • 2019-08-09
            • 2014-02-07
            • 1970-01-01
            • 1970-01-01
            • 2020-12-07
            相关资源
            最近更新 更多