Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

117 строки
3.2 KiB

  1. var expect = require('chai').expect;
  2. var webdriver = require('selenium-webdriver');
  3. var driver = require('./driver');
  4. var servers = require('./servers');
  5. var elements = [
  6. 'swagger-ui-container',
  7. 'resources_container',
  8. 'api_info',
  9. 'resource_pet',
  10. 'resource_store',
  11. 'resource_user',
  12. 'header'
  13. ];
  14. describe('swagger 2.0 spec tests', function (done) {
  15. this.timeout(10 * 1000);
  16. before(function (done) {
  17. this.timeout(25 * 1000);
  18. servers.start('/v2/petstore.json', done);
  19. });
  20. afterEach(function(){
  21. it('should not have any console errors', function (done) {
  22. driver.manage().logs().get('browser').then(function(browserLogs) {
  23. var errors = [];
  24. browserLogs.forEach(function(log){
  25. // 900 and above is "error" level. Console should not have any errors
  26. if (log.level.value > 900)
  27. console.log('browser error message:', log.message); errors.push(log);
  28. });
  29. expect(errors).to.be.empty;
  30. done();
  31. });
  32. });
  33. });
  34. it('should have "Swagger UI" in title', function (done) {
  35. driver.sleep(200);
  36. driver.getTitle().then(function(title) {
  37. expect(title).to.contain('Swagger UI');
  38. done();
  39. });
  40. });
  41. elements.forEach(function (id) {
  42. it('should render element: ' + id, function (done) {
  43. var locator = webdriver.By.id(id);
  44. driver.isElementPresent(locator).then(function (isPresent) {
  45. expect(isPresent).to.be.true;
  46. done();
  47. });
  48. });
  49. });
  50. it('should find the contact name element', function(done){
  51. var locator = webdriver.By.css('.info_name');
  52. driver.isElementPresent(locator).then(function (isPresent) {
  53. expect(isPresent).to.be.true;
  54. done();
  55. });
  56. });
  57. it('should find the contact email element', function(done){
  58. var locator = webdriver.By.css('.info_email');
  59. driver.isElementPresent(locator).then(function (isPresent) {
  60. expect(isPresent).to.be.true;
  61. done();
  62. });
  63. });
  64. it('should find the contact url element', function(done){
  65. var locator = webdriver.By.css('.info_url');
  66. driver.isElementPresent(locator).then(function (isPresent) {
  67. expect(isPresent).to.be.true;
  68. done();
  69. });
  70. });
  71. it('should find the pet link', function(done){
  72. var locator = webdriver.By.xpath("//*[@data-id='pet']");
  73. driver.isElementPresent(locator).then(function (isPresent) {
  74. expect(isPresent).to.be.true;
  75. done();
  76. });
  77. });
  78. it('should find the pet resource description', function(done){
  79. var locator = webdriver.By.xpath("//div[contains(., 'Everything about your Pets')]");
  80. driver.findElements(locator).then(function (elements) {
  81. expect(elements.length).to.not.equal(0);
  82. done();
  83. });
  84. });
  85. it('should find the user link', function(done){
  86. var locator = webdriver.By.xpath("//*[@data-id='user']");
  87. driver.isElementPresent(locator).then(function (isPresent) {
  88. expect(isPresent).to.be.true;
  89. done();
  90. });
  91. });
  92. it('should find the store link', function(done){
  93. var locator = webdriver.By.xpath("//*[@data-id='store']");
  94. driver.isElementPresent(locator).then(function (isPresent) {
  95. expect(isPresent).to.be.true;
  96. done();
  97. });
  98. });
  99. after(function() {
  100. servers.close();
  101. });
  102. });