0

Web アプリのテストでステートメントを使用しassertTrueていますが、テキストが Web に存在していても false を返します。どうすればこれを修正できますか?

public void Test1() throws Exception {
    Selenium selenium = new DefaultSelenium("localhost",1777,"*chrome","http://www.mortgagecalculator.org/");
    selenium.start(); 

   try {     
                 selenium.open("/");
                 Thread.sleep(3000);
                 selenium.windowMaximize();
                     selenium.type("name=param[homevalue]", "400000");
             selenium.type("name=param[principal]", "7888800");
             selenium.select("name=param[rp]", "label=New Purchase");
             selenium.type("name=param[interest_rate]", "8");
             selenium.type("name=param[term]", "35");
             selenium.select("name=param[start_month]", "label=May");
             selenium.select("name=param[start_year]", "label=2006");
             selenium.type("name=param[property_tax]", "7.5");
             selenium.type("name=param[pmi]", "0.8");
             selenium.click("css=input[type=\"submit\"]");
             assertTrue(selenium.isTextPresent("$58,531.06"));
             System.out.println("Assert Statement executed");
             selenium.stop();
    } 
   catch (Exception e) {
        System.out.println("In Mortgage Calculator App exception Happened"); 
                                                 }  
   }
4

1 に答える 1

0

私はあなたのテストを実行しましたが、私には問題ないようですが、これはここにあるという事実に関係していると思われます:

selenium.click("css=input[type=\"submit\"]");
assertTrue(selenium.isTextPresent("$58,531.06"));

待機する必要がないため、ページ/結果が assertTrue に移動するときにテストが爆破されないほど速くロードされる場合にのみ、「$58,531.06」が正常に検出されます。

おそらく代わりにここで「waitForTextPresent」を使用するか、そこに何かを配置して、テストが結果を確認する前にロードできることを確認することをお勧めします。

それが役立つことを願っています。

于 2012-07-20T13:25:34.087 に答える