Created
          January 7, 2014 02:53 
        
      - 
      
- 
        Save sebv/8293982 to your computer and use it in GitHub Desktop. 
    wd async error handling
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require('colors'); | |
| var wd; | |
| try { | |
| wd = require('wd'); | |
| } catch( err ) { | |
| wd = require('../../lib/main'); | |
| } | |
| var browser = wd.remote(); | |
| // optional extra logging | |
| browser.on('status', function(info) { | |
| console.log(info.cyan); | |
| }); | |
| browser.on('command', function(meth, path, data) { | |
| console.log(' > ' + meth.yellow, path.grey, data || ''); | |
| }); | |
| browser.init({browserName:'chrome'}, function() { | |
| browser.get("http://admc.io/wd/test-pages/guinea-pig.html", function() { | |
| browser.waitForElementById('i don\'t exist', function(err, el) { | |
| console.log('got error -->', err); | |
| }); | |
| }); | |
| }); | |
| // CONSOLE OUTPUT | |
| // | |
| // node examples/async/async-error-handling.js | |
| // Driving the web on session: 897bd93f-891d-4f72-ad11-bb4b69ea6b38 | |
| // > POST /session/:sessionID/url { url: 'http://admc.io/wd/test-pages/guinea-pig.html' } | |
| // > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' } | |
| // > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' } | |
| // > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' } | |
| // > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' } | |
| // > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' } | |
| // > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' } | |
| // > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' } | |
| // got error --> [Error: Element condition wasn't satisfied!] | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment