multipleDropdowns.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { describe, it, before, after } from 'mocha'
  2. import { expect } from 'chai'
  3. import { By, until, Condition, Key } from 'selenium-webdriver'
  4. import {
  5. getRootAndWait,
  6. getActionButtons,
  7. takeScreenshotOnFailure,
  8. waitForArgumentFormPage,
  9. waitForArgumentFormReady,
  10. } from '../../lib/elements.js'
  11. describe('config: multipleDropdowns', function () {
  12. before(async function () {
  13. await runner.start('multipleDropdowns')
  14. })
  15. after(async () => {
  16. await runner.stop()
  17. })
  18. afterEach(function () {
  19. takeScreenshotOnFailure(this.currentTest, webdriver);
  20. });
  21. it('Multiple dropdowns are possible', async function() {
  22. await getRootAndWait()
  23. // Wait for action buttons to be rendered
  24. await webdriver.wait(new Condition('wait for action buttons', async () => {
  25. const btns = await webdriver.findElements(By.css('.action-button button'))
  26. return btns.length >= 2
  27. }), 10000)
  28. const buttons = await getActionButtons()
  29. let button = null
  30. for (const b of buttons) {
  31. const title = await b.getAttribute('title')
  32. if (title === 'Test multiple dropdowns') {
  33. button = b
  34. }
  35. }
  36. expect(buttons).to.have.length(2)
  37. expect(button).to.not.be.null
  38. await button.click()
  39. await waitForArgumentFormPage(8000)
  40. await waitForArgumentFormReady(10000)
  41. await webdriver.wait(new Condition('wait for choice comboboxes', async () => {
  42. const boxes = await webdriver.findElements(By.css('main .choice-combobox'))
  43. return boxes.length >= 2
  44. }), 10000)
  45. const comboboxes = await webdriver.findElements(By.css('main .choice-combobox'))
  46. expect(comboboxes).to.have.length(2)
  47. const firstInput = await comboboxes[0].findElement(By.css('.choice-combobox-input'))
  48. await firstInput.click()
  49. await webdriver.wait(new Condition('wait for first combobox list', async () => {
  50. const lists = await comboboxes[0].findElements(By.css('.choice-combobox-list li'))
  51. return lists.length === 2
  52. }), 2000)
  53. await firstInput.sendKeys(Key.TAB)
  54. await webdriver.wait(new Condition('wait for second combobox list', async () => {
  55. const lists = await comboboxes[1].findElements(By.css('.choice-combobox-list li'))
  56. return lists.length === 3
  57. }), 2000)
  58. })
  59. })