Tuesday 30 May 2017

Cannot trap Selenium Webdriver Error

I have this block of code:

 it('tests cookies', opts, t => {
    driver.get(`${cdthost}/#!/my-acquisitions/${acqId}`).then(function () {
      return Promise.delay(3000);
    });
    driver.wait(until.elementLocated(By.id(`acq-dropdown-item-${acqId}`)), 4000).then(function () {
      console.log(`acq-dropdown-item-${acqId} has been located.`);
    });
    driver.findElement(By.id(`acq-dropdown-item-${acqId}`)).click();
    return driver.getCurrentUrl().then(function (val) {
      assert(val === `${cdthost}/#!/my-acquisitions/${acqId}`)
    })
    .catch(function (err) {
      console.error(' => Trapped error => ',err.stack || err);
    })

  });

It would seem that the catch callback would capture errors. I am getting this error from the above routine:

    WebDriverError: 
Capabilities [{moz:profile=/var/folders/b9/3bk4d8cs0nvb1swfzncgncx00000gn/T/rust_mozprofile.A3epOylmsbmW, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0.3, platformVersion=16.6.0, moz:processID=63613.0, browserName=firefox, javascriptEnabled=true, platformName=darwin}]

The weird thing, though, is that this error does not appear in the catch block, and is being thrown or captured elsewhere. Anyone have any idea what might be going on?

FWIW acq-dropdown-item-${acqId} has been located., does get logged.



via Alexander Mills

No comments:

Post a Comment