2016-05-27 5 views
0

何とかデフォルト値'01/01/2000 'に追加された値を送信すると、問題が発生しています。私は成功することなくこれを行うためにさまざまな方法を試しました。私はこれらの正確な行を他のスクリプトで使っていましたが、うまくいきましたが、なぜここではうまくいかないのか分かりません。私が使用した最後のコードの下に、問題が表示された画像が続きます。任意の応答を事前にSendKeys()がデフォルト値(issue)+ datetime値を追加しました

var targetStartDate = browser.driver.findElement(by.id('StartDate')); 
    targetStartDate.clear().then(function() {   
     targetStartDate.sendKeys('09/01/2016');   
    }) 

example of the issue

感謝。

答えて

1

あなたは鍵を送信する前にclear()コールを発行しようとすることができます

targetStartDate.clear(); 
targetStartDate.sendKeys('09/01/2016'); 

他のオプションは、前のキーを送信する入力内のすべてのテキストを選択するには、次のようになります。

// protractor.Key.COMMAND on Mac 
targetStartDate.sendKeys(protractor.Key.chord(protractor.Key.CONTROL, "a")); 
targetStartDate.sendKeys('09/01/2016'); 
0

私はこれと同じに遭遇しました前に問題を起こす。フィールドに入力をフォーマットする入力マスクがあります。それが実際のユーザーであるかのように、これを解決するために、あなたは心の中でフォーマットして、あなたのテストを記述する必要があります。

var targetStartDate = browser.driver.findElement(by.id('StartDate')); 
// Remove the forward slashes because the input field takes care of that. 
var inputDate = '09012016'; 

targetStartDate.clear(); 
// Loop through each character of the string and send it to the input 
// field followed by a delay of 250 milliseconds to give the field 
// enough time to format the input as you keep sending keys. 
for (var i = 0; i < inputDate.length; i++) { 
    targetStartDate.sendKeys(inputDate[i]); 
    browser.driver.sleep(250); 
} 

サイトや性能のレイテンシーに応じて、250を減少させる必要があるかもしれませんどちらかミリ秒の遅延、またはそれを減らすことができます。

希望すると便利です。

関連する問題