Search code examples
intern

How can I get a value from .getVisibleText() to my variable?


How can I get a value from .getVisibleText() to my variable?

.getVisibleText return a command object to use .then with it. But is there any way to get the text to my own variable?


Solution

  • Writing a functional test shows an example that would make want to try

    define(function (require) {
      var registerSuite = require('intern!object');
    
      registerSuite(function() {
        var YOUR_VARIABLE;
    
        return {
          name: 'index',
    
          'greeting form': function() {
            return this.remote
              .get(require.toUrl('index.html'))
              .setFindTimeout(5000)
              .findById('greeting')
                .getVisibleText()
                .then(function (text) {
                  YOUR_VARIABLE = text;
                });
          }
        };
      });
    });