[x-pack/test] convert PO to typescript, improve find/testSubject usage#77389
Conversation
| * under the License. | ||
| */ | ||
|
|
||
| import { Key } from 'selenium-webdriver'; |
There was a problem hiding this comment.
Using browser service instead so that we can easily migrate to other test library
| import http, { IncomingMessage } from 'http'; | ||
| import { FtrProviderContext } from 'test/functional/ftr_provider_context'; | ||
| import { parse } from 'url'; | ||
| import { FtrProviderContext } from '../ftr_provider_context'; |
| return await retry.try(async () => { | ||
| log.debug(`expectUpgradeAssistant()`); | ||
| expect(testSubjects.exists('upgradeAssistantRoot')).to.be.true; | ||
| expect(await testSubjects.exists('upgradeAssistantRoot')).to.equal(true); |
There was a problem hiding this comment.
missing await could be a reason of flakiness
| async findFirstActionsButton() { | ||
| await this.ensureIsOnPolicyPage(); | ||
| return (await testSubjects.findAll('policyActionsButton'))[0]; | ||
| return await testSubjects.find('policyActionsButton'); |
There was a problem hiding this comment.
testSubjects.find wraps driver.findElement that will return the first element in DOM with specified locator and throw exception in case it is not in DOM. It is better than searching for an array and selecting by index when array can be empty.
💚 Build SucceededBuild metrics
To update your PR or re-run it, just comment with: |
| await actionsButton.click(); | ||
| const deleteAction = await testSubjects.find('policyDeleteButton'); | ||
| await deleteAction.click(); | ||
| await testSubjects.click('policyDeleteButton'); |
There was a problem hiding this comment.
@dmlemeshko will testSubjects.click() wait for the test subject to appear before it attempts the click?
There was a problem hiding this comment.
Yes @charlie-pichette, it will. If you need to change default timeout, you can pass it this way:
await testSubjects.click('policyDeleteButton', 25000);
charlie-pichette
left a comment
There was a problem hiding this comment.
Changes to the security solution files look good to me. Thanks for making the changes @dmlemeshko. 👍
elastic#77389) # Conflicts: # test/functional/page_objects/vega_chart_page.ts # x-pack/test/functional/page_objects/gis_page.ts # x-pack/test/functional/page_objects/uptime_page.ts # x-pack/test/security_solution_endpoint/page_objects/ingest_manager_create_package_policy_page.ts
Summary
Checklist
Delete any items that are not applicable to this PR.
For maintainers