4

我是 jasmine 和 webdriverio 的新手,我试图在“描述”中执行多个“it”函数,但不能执行多个 it 语句。

下面是代码。

var webdriverio = require('webdriverio');
var options = { desiredCapabilities: { browserName: 'chrome' } };
var client = webdriverio.remote(options);

describe('Login Test for ES1', function () {
  var session = client
    .init()
    .timeoutsImplicitWait(3000)
    .url('myapp url');


  it('Navigated url contains Title ES1', function (done) {
    session.getTitle(function(error,title) {
      expect(error).toBeFalsy();
      expect(title).toBe('title');
      done();
     })
  });

  it('has the login button', function (complete) {
    session
     .getText("a.login",function(error,text){
      expect(error).toBeFalsy();
      expect(text).toBe('Login with Google');
      complete();
     })
   });

  it('User able to login using google', function (finished) {
    session
     .click('a.login')
     .element('#Email').keys('username')
     .click('#next').pause(1000)
     .element('#Passwd').keys('password')
     .click("#signIn").pause(1000)
     .getText('//*[@id="context"]/div/div',function(error,text){
      expect(text).toContain('User Name');
     })
     .end(finished);
  });
});

下面是终端输出

 1 Login Test for ES1
    ✓ Navigated url contains Title ES1

另一个它没有被执行。如果我删除其中的所有回调(完成、完成、完成)。甚至在测试执行之前,所有这些都通过了。

如果我删除所有回调,以下是输出

1 Login Test for ES1
    ✓ Navigated url contains Title ES1
    ✓ has the login button
    ✓ User able to login using google

Executed 3 of 3 specs SUCCESS in 0.017 sec.
At least one spec has failed
RuntimeError: Session ID is null. Using WebDriver after calling quit()?
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'MacBook-Pro.local', ip: '174.165.174.131', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.5', java.version: '1.8.0_60'
Driver info: driver.version: EventFiringWebDriver 

让我知道这里出了什么问题以及应该如何执行异步测试

4

0 回答 0