How to click on Button until a dependent value reaches a certain value?

前端 未结 2 459
余生分开走
余生分开走 2021-01-24 14:20

With Protractor I\'m trying to automate a part of a UI, in which with plus-minus buttons a min-max-range (i.e. 100\'000-200\'000) is selected.

There is an inputAmo

2条回答
  •  醉酒成梦
    2021-01-24 15:02

    Since javascript is asynchronous, you need to resolve the promise before accessing the return value from the promise. In your case, you need to implement recursion to make your method to click the slider until required value is set. Have a look at below example.

    var selectAmountRange = function(inputAmount) {
         $('.max').getText().then(function(currentMax){
             var btnPlus = $('.slider-buttons .slider-button-plus');
              if(currentMax < selectAmountRange){
                  btnPlus.click();
                  browser.sleep(3000);
                  selectAmountRange(inputAmount); //call the same method untill required inputAmount is selcted.
              }
         }; 
    };
    

提交回复
热议问题