2016-11-16 18 views
0

Selenium + mochaでURLにアクセスする際に問題が発生しました。これは私が使用しているコード行です。FirefoxでSelenium get(url)問題が発生しました

return driver.get('http://localhost/ClickSuscribe/#/MisProductos') 

私は角のURLにいくつかの問題があることがわかりましたが、解決策は見つかりませんでした。

it("Is visible", function() { 
     if(viable) 
     { 
      return driver.findElements(webdriver.By.id('activarMiSitio')).then(function(misProductos){ 
       misProductos[0].getAttribute("class").then(function(webElement){ 
        if(webElement==='ng-hide') 
        { 
         console.log('Element not found'); 
        } 
        else{ 
         console.log('Element exists'); 
        } 
       }).then(function(){ 
        driver.sleep(500); 
        //return driver.get('http://localhost/ClickSuscribe/#').catch(r => console.log(r)); 
        return driver.get('http://localhost/ClickSuscribe/#/MisProductos').catch(r => console.log(r)); 
       });/*.then(function(){ 
        driver.sleep(2000); 
        return driver.getCurrentUrl(); 
       }).then(function(currentUrl){ 
        driver.sleep(1000); 
        console.log(currentUrl); 
       });*/ 
      }); 
     } 
     return console.log("No está loggeado"); 
    }); 

PS:これはChromeとIEで動作し

エラーがError: timeout of 40000ms exceeded. Ensure the done() callback is being called in this test.

であるこれは、テストケースです。セレンには、アンカーまたはポンドのURL「#」を処理する問題があるようです。

+0

は、メソッドまたはスクリプトの実行を取得する際の問題ですか? –

+0

@MohamedELAYADI私は実際にはわかりませんが、getメソッドを使用している可能性が最も高いと思われます。約1分間そこにいれば、次のテストが続行されるからです。 –

答えて

0

エラー

が行わ()コールバックは、この試験で呼び出されていることを確認言います。

次のようにdoneコールバックを注入することができます

it("Is visible", function(done) { 
    //... 
}); 

、テストごとに行わのタイムアウトを設定します。

describe('...', function(){ 
    this.timeout(15000); 

    it('...', function(done){ 
    this.timeout(15000); 
    setTimeout(done, 15000); 
    }); 
}); 

詳細情報がありin the docs

を見つけることができますまたknown issuesなので、依存関係をアップグレードすることをお勧めします。

+0

この回答の前半は間違っています。エラーメッセージは誤解を招くことです。 OPは約束を使用していますが、約束を返すことは、非同期テストを待つためにモカが必要とするものです。特に、 'driver.get(...)'の直後に 'done()'を呼び出すと、 'get'操作が完了する前にテストが完了するようになります。 – Louis

+0

ありがとう、私は答えを変更しましたが、おそらくこれ以上実際には役に立たないでしょう。 –

+0

私がmochaと理解している通りに、あなたは約束を返さなければなりません。 また、私は 'after(function(done){ driver.quit()then then(done); }}) –

関連する問題