2017-04-23 5 views
0

オブジェクトがロケータかElementFinderかどうかをチェックする関数を書く必要があります。私はtypeofを使用しようとしましたが、成功しません。何か案が?オブジェクトがProtractorJSのロケータかElementFinderかどうかをチェック

+1

関連するコードも追加できますか? – Grasshopper

+0

これは何が起こっているのか理解するのが難しいです。関連コード、分度器の設定、コンソール出力、エラーメッセージなど。質問の現状では、私があなたに与える最良の答えは、ドキュメントを読むことです。あなたは 'instanceof ElementFinder'を試すことができます。それはちょうど推測です。 – cnishina

答えて

0

ElementFinderでは使用できる機能を使用できますが、ロケータでは使用できません。

var isElementFinder = function(obj) { 
    try { 
     // you don't care about this output, just that the function can execute 
     obj.getTagName(); 
     return true; 
    } catch(e) { 
     // for any object that is not an ElementFinder, 
     // this should throw an error that 'getTagName' is not defined 
     return false; 
    } 
} 
関連する問題