|
8 | 8 | import { adminTestUser } from '@kbn/test'; |
9 | 9 | import { AuthenticatedUser, Role } from '@kbn/security-plugin/common/model'; |
10 | 10 | import type { UserFormValues } from '@kbn/security-plugin/public/management/users/edit_user/user_form'; |
| 11 | +import { Key } from 'selenium-webdriver'; |
11 | 12 | import { FtrService } from '../ftr_provider_context'; |
12 | 13 |
|
13 | 14 | interface LoginOptions { |
@@ -359,14 +360,12 @@ export class SecurityPageObject extends FtrService { |
359 | 360 | } |
360 | 361 |
|
361 | 362 | async addPrivilegeToRole(privilege: string) { |
362 | | - this.log.debug(`Adding privilege ${privilege} to role`); |
363 | | - const privilegeInput = await this.retry.try(() => |
364 | | - this.find.byCssSelector('[data-test-subj="privilegesInput0"] input') |
365 | | - ); |
366 | | - await privilegeInput.type(privilege); |
367 | | - |
368 | | - const btn = await this.find.byButtonText(privilege); |
369 | | - await btn.click(); |
| 363 | + this.log.debug(`Adding privilege "${privilege}" to role`); |
| 364 | + const privilegesField = await this.testSubjects.find('privilegesInput0'); |
| 365 | + const privilegesInput = await privilegesField.findByTagName('input'); |
| 366 | + await privilegesInput.type(privilege); |
| 367 | + await privilegesInput.pressKeys(Key.ENTER); // Add typed privilege to combo box |
| 368 | + await privilegesInput.pressKeys(Key.ESCAPE); // Close dropdown menu to avoid hiding elements from test runner |
370 | 369 | } |
371 | 370 |
|
372 | 371 | async assignRoleToUser(role: string) { |
@@ -586,23 +585,27 @@ export class SecurityPageObject extends FtrService { |
586 | 585 | } |
587 | 586 |
|
588 | 587 | await this.testSubjects.click('addSpacePrivilegeButton'); |
589 | | - await this.testSubjects.click('spaceSelectorComboBox'); |
| 588 | + const spaceSelectorComboBox = await this.testSubjects.find('spaceSelectorComboBox'); |
| 589 | + await spaceSelectorComboBox.click(); |
590 | 590 |
|
591 | 591 | const globalSpaceOption = await this.find.byCssSelector(`#spaceOption_\\*`); |
592 | 592 | await globalSpaceOption.click(); |
593 | 593 |
|
| 594 | + // Close dropdown menu to avoid hiding elements from test runner |
| 595 | + const spaceSelectorInput = await spaceSelectorComboBox.findByTagName('input'); |
| 596 | + await spaceSelectorInput.pressKeys(Key.ESCAPE); |
| 597 | + |
594 | 598 | await this.testSubjects.click('basePrivilege_all'); |
595 | 599 | await this.testSubjects.click('createSpacePrivilegeButton'); |
596 | 600 |
|
597 | | - const addPrivilege = (privileges: string[]) => { |
| 601 | + const addPrivileges = (privileges: string[]) => { |
598 | 602 | return privileges.reduce((promise: Promise<any>, privilegeName: string) => { |
599 | 603 | return promise |
600 | 604 | .then(() => self.addPrivilegeToRole(privilegeName)) |
601 | 605 | .then(() => this.common.sleep(250)); |
602 | 606 | }, Promise.resolve()); |
603 | 607 | }; |
604 | | - |
605 | | - await addPrivilege(roleObj.elasticsearch.indices[0].privileges); |
| 608 | + await addPrivileges(roleObj.elasticsearch.indices[0].privileges); |
606 | 609 |
|
607 | 610 | const addGrantedField = async (fields: string[]) => { |
608 | 611 | for (const entry of fields) { |
|
0 commit comments