Wait for user action

I am looking for a solution if it is possible to wait for the data entered by the user into the protractor.

I mean stopping the test for a while, and I can enter some value, and then this data is used in further tests.

I tried to use the javascript prompt but I didn't do much, maybe it is possible to enter data into the OS terminal?

Please give me an example if possible.

+3


source to share


2 answers


I would not recommend mixing automatic and manual selenium browser controls.

However, you can use Explicit Waits to wait for certain things to appear on the page, for example. you can wait for the text to appear in the text, input

or the element to become visible, or the page title to equal the expected, there are various ExpectedConditions built in protractor

and you can easily write your own expected conditions for the wait. You should have set a reasonable timeout though.


Alternatively, you can pass custom parameters via browser.params

, see



Example:

protractor my.conf.js --params.login.user=abc --params.login.password=123

      

Then you can access the values ​​in your test via browser.params

:

var login = element(by.id("login"));
login.sendKeys(browser.params.login.user);

      

+1


source


If your data is going to be in the console, you can get that data using the following:

browser.manage().logs().get('browser').then(function(browserLogs) {
   // browserLogs is an array which can be filtered by message level
   browserLogs.forEach(function(log){
      if (log.level.value < 900) { // non-error messages
        console.log(log.message);
      }
   });
});

      

Then, as mentioned in other posts, you can explicitly expect the condition to be true using driver.wait ():



var started = startTestServer(); 
driver.wait(started, 5 * 1000, 
'Server should start within 5 seconds'); 
driver.get(getServerUrl());

      

Or expected conditions if you are expecting more than one condition, for example.

0


source







All Articles