zombie.js如何从下拉列表中选择

时间:2016-03-30 22:53:15

标签: forms browser-automation zombie.js

我有一个空白页面,其中包含一个包含IP地址的选择框。作为值,我想使用zombine.js中的一个选择单个值。

this.browser.fill('select', '223.255.252.246');

这失败^

但这成功了:

this.browser.assert.element('select')

我缺少什么?是不是"填充" ?

这是我的测试

// force the test environment to 'test'
process.env.NODE_ENV = 'test';
// get the application server module
var app = require('../../app');
var http = require('http');
var Browser = require('zombie');
var assert = require('assert');

describe('contact page', function() {
  before(function(done) {
    this.server = http.createServer(app).listen(3000);// initialize the browser using the same port as the test application
    this.browser = new Browser({ site: 'http://localhost:3000' });
    this.browser.visit('/', done);
  });

  it('should load the homepage successfully', function(){
    assert.ok(this.browser.success);
  });

  it('shows a dropdown', function(){
    this.browser.assert.element('select')
  });

  it('selects china, and clicks "start"', function(){
    this.browser.fill('select', '223.255.252.246');
  });
  // ...

  after(function(done) {
    this.server.close(done);
  });
});

1 个答案:

答案 0 :(得分:3)

答案是使用"选择" e.g:

try {
    $myService->doFoo();
    $success = 'Congratulations! It worked!';
} catch (ExceptionOne $e) {
    $error = 'Exception one occurred. Please try this instead.'
} catch (ExceptionTwo $e) {
    $error = 'Exception two occurred. Please try this instead.'
} catch (ExceptionThree $e) {
    $error = 'Exception three occurred. Please try this instead.'
} catch (ExceptionFour $e) {
    $error = 'Exception four occurred. Please try this instead.'
} catch (ExceptionFive $e) {
    $error = 'Exception five occurred. Please try this instead.'
} catch (ExceptionSix $e) {
    $error = 'Exception six occurred. Please try this instead.'
} catch (ExceptionSeven $e) {
    $error = 'Exception seven occurred. Please try this instead.'
} catch (ExceptionEight $e) {
    $error = 'Exception eight occurred. Please try this instead.'
} catch (ExceptionNine $e) {
    $error = 'Exception nine occurred. Please try this instead.'
}
return $this->render('Bundle:Foo:bar.html.twig', [
    'success' => $success,
    'error' => $error,
]);