Skip to content

fix(protocol-designer) refactor cypress locators to be less brittle #17891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: edge
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
17dc2d4
removed unused locator and updated checkbox
skowalski08 Mar 25, 2025
a9818fb
added function to close release notes modal
skowalski08 Mar 25, 2025
aa75922
removed incorrect locator
skowalski08 Mar 25, 2025
a24bcf9
removed incorrect locator
skowalski08 Mar 25, 2025
0e8df82
removed unused locators, and updated brittle locators
skowalski08 Mar 26, 2025
dd78ef1
removed comments and updated locators
skowalski08 Mar 26, 2025
f0e7ff9
removed comment
skowalski08 Mar 26, 2025
68c278d
highlighted questionable locators with //NOTE
skowalski08 Mar 26, 2025
2d5a621
Merge branch 'edge' into PD-locator-refactor
skowalski08 Mar 26, 2025
8e33ee4
Merge branch 'edge' into PD-locator-refactor
skowalski08 Mar 26, 2025
425e360
addressed everything but some of the checkboxes and one dropdown menu…
alexjoel42 Mar 28, 2025
b64af4a
Merge branch 'edge' into PD-locator-refactor
skowalski08 Mar 28, 2025
3870cd9
linting changes
skowalski08 Mar 28, 2025
b69770f
fix lint and stuff
skowalski08 Mar 28, 2025
aadc8b6
Merge branch 'edge' into PD-locator-refactor
skowalski08 Mar 31, 2025
270febf
Merge branch 'edge' of github.com:Opentrons/opentrons into edge
skowalski08 Mar 31, 2025
b8d05f0
Merge remote-tracking branch 'origin/PD-locator-refactor' into PD-loc…
skowalski08 Mar 31, 2025
f9cb783
fix formatting issues
skowalski08 Mar 31, 2025
c89b5a1
Merge branch 'edge' into PD-locator-refactor
skowalski08 Mar 31, 2025
f44918e
Merge branch 'edge' into PD-locator-refactor
skowalski08 Apr 1, 2025
00c5e9c
Merge branch 'edge' into PD-locator-refactor
skowalski08 Apr 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions protocol-designer/cypress/e2e/mixSettings.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('Redesigned Mixing Steps - Happy Path', () => {
beforeEach(() => {
cy.visit('/')
cy.closeAnalyticsModal()
cy.closeReleaseNotesModal()
const protocol = getTestFile(TestFilePath.DoItAllV8)
cy.importProtocol(protocol.path)
verifyImportProtocolPage(protocol)
Expand Down
17 changes: 9 additions & 8 deletions protocol-designer/cypress/e2e/plateReaderTest.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { SetupSteps, SetupVerifications } from '../support/SetupSteps'
import {
SetupSteps,
SetupVerifications,
CompositeSetupSteps,
} from '../support/SetupSteps'
import { ModuleSteps, ModuleVerifications } from '../support/ModuleSteps'
import { UniversalSteps } from '../support/UniversalSteps'
import { StepBuilder } from '../support/StepBuilder'
Expand Down Expand Up @@ -44,11 +48,9 @@ describe('Plate Reader Happy Path Single-Wavelength', () => {
steps.add(SetupSteps.Confirm())
steps.add(SetupSteps.Confirm())
steps.add(SetupSteps.EditProtocolA())
steps.add(SetupSteps.ChoseDeckSlotWithLabware('C3'))
steps.add(SetupSteps.AddHardwareLabware())
steps.add(SetupSteps.ClickLabwareHeader())
steps.add(SetupSteps.ClickWellPlatesSection())
steps.add(SetupSteps.SelectLabwareByDisplayName('Bio-Rad 96 Well Plate'))
steps.add(
CompositeSetupSteps.AddLabwareToDeckSlot('C3', 'Bio-Rad 96 Well Plate')
)
steps.add(SetupSteps.ChoseDeckSlotWithLabware('C3'))
steps.add(SetupSteps.AddLiquid())
steps.add(SetupSteps.ClickLiquidButton())
Expand Down Expand Up @@ -81,7 +83,7 @@ describe('Plate Reader Happy Path Single-Wavelength', () => {
steps.add(SetupSteps.Save())
steps.add(ModuleVerifications.NoMoveToPlateReaderWhenClosed())
// You can't move to Plate Reader while it's closed
steps.add(SetupSteps.DeleteSteps())
steps.add(SetupSteps.DeleteSteps('1. Move'))
steps.add(SetupSteps.AddStep())
steps.add(ModuleSteps.StartPlateReaderStep())
steps.add(ModuleVerifications.PlateReaderPart1NoInitilization())
Expand All @@ -91,7 +93,6 @@ describe('Plate Reader Happy Path Single-Wavelength', () => {
steps.add(ModuleSteps.DefineInitilizationSingleCheckAll())
steps.add(ModuleSteps.DefineCustomWavelegthSingle('300'))
steps.add(SetupSteps.Save())

steps.execute()
})
})
24 changes: 12 additions & 12 deletions protocol-designer/cypress/e2e/transferSettings.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { SetupSteps, SetupVerifications } from '../support/SetupSteps'
import {
SetupSteps,
SetupVerifications,
CompositeSetupSteps,
} from '../support/SetupSteps'
import { UniversalSteps } from '../support/UniversalSteps'
import { StepBuilder } from '../support/StepBuilder'

Expand Down Expand Up @@ -47,12 +51,10 @@ describe('Transfer stepform testing Single Channel - Happy Path', () => {
steps.add(SetupSteps.Confirm())
steps.add(SetupSteps.Confirm())
steps.add(SetupSteps.EditProtocolA())
steps.add(SetupSteps.ChoseDeckSlot('C2'))
steps.add(SetupSteps.AddHardwareLabware())
steps.add(SetupSteps.ClickLabwareHeader())
steps.add(SetupSteps.ClickWellPlatesSection())
steps.add(SetupSteps.SelectLabwareByDisplayName('Bio-Rad 96 Well Plate'))
steps.add(SetupSteps.ChoseDeckSlotC2Labware())
steps.add(
CompositeSetupSteps.AddLabwareToDeckSlot('C2', 'Bio-Rad 96 Well Plate')
)
steps.add(SetupSteps.ChoseDeckSlotWithLabware('C2'))
steps.add(SetupSteps.AddLiquid())
steps.add(SetupSteps.ClickLiquidButton())
steps.add(SetupSteps.DefineLiquid())
Expand All @@ -63,11 +65,9 @@ describe('Transfer stepform testing Single Channel - Happy Path', () => {
steps.add(UniversalSteps.Snapshot())
steps.add(SetupSteps.SelectLiquidWells())
steps.add(SetupSteps.SetVolumeAndSaveForWells('150'))
steps.add(SetupSteps.ChoseDeckSlot('C3'))
steps.add(SetupSteps.AddHardwareLabware())
steps.add(SetupSteps.ClickLabwareHeader())
steps.add(SetupSteps.ClickWellPlatesSection())
steps.add(SetupSteps.SelectLabwareByDisplayName('Bio-Rad 96 Well Plate'))
steps.add(
CompositeSetupSteps.AddLabwareToDeckSlot('C3', 'Bio-Rad 96 Well Plate')
)
steps.add(SetupSteps.ProtocolStepsH())
steps.add(SetupSteps.AddStep())
steps.add(SetupVerifications.TransferPopOut())
Expand Down
41 changes: 22 additions & 19 deletions protocol-designer/cypress/support/MixSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,19 @@ enum MixLocators {
AspFlowRateInput = '[name="aspirate_flowRate"]',
AspWellOrder = '[data-testid="WellsOrderField_ListButton_aspirate"]',
ResetToDefault = 'button:contains("Reset to default")',
PrimaryOrderDropdown = 'div[tabindex="0"].sc-bqWxrE jKLbYH iFjNDq',
CancelAspSettings = 'button:contains("Done")',
MixTipPos = '[data-testid="PositionField_ListButton_mix"]',
XpositionInput = '[data-testid="TipPositionModal_x_custom_input"]',
YpositionInput = '[id="TipPositionModal_y_custom_input"]',
ZpositionInput = '[id="TipPositionModal_z_custom_input"]',
SwapView = 'button:contains("Swap view")',
Checkbox = '[class="Flex-sc-1qhp8l7-0 Checkbox___StyledFlex3-sc-1mvp7vt-0 gZwGCw btdgeU"]',
DelaySecondsInput = '[class="InputField__StyledInput-sc-1gyyvht-0 cLVzBl"]',
Checkbox = '[data-testid="ListButton_noActive"]',
DispFlowRate = '[name="dispense_flowRate"]',
BlowoutLtnDropdown = '[class="Svg-sc-1lpozsw-0 Icon___StyledSvg-sc-1gt4gyz-0 csSXbR cJpxat"]',
BlowoutFlowRate = '[name="blowout_flowRate"]',
BlowoutPos = '[id="TipPositionField_blowout_z_offset"]',
BlowoutZPosition = '[data-testid="TipPositionModal_custom_input"]',
PosFromBottom = '[id="TipPositionField_mix_touchTip_mmFromBottom"]',
RenameBtn = 'button:contains("Rename")',
StepNameInput = '[class="InputField__StyledInput-sc-1gyyvht-0 cLVzBl"]',
// StepNotesInput = '[class="TextAreaField__StyledTextArea-sc-1mhuse7-0 hpcyEZ"]',
StepNameInput = 'div[tabindex="0"]',
StepNotesInput = '[data-testid="TextAreaField"]',
PosFromTop = '[data-testid="TipPositionField_mix_touchTip_mmFromTop"]',
}
Expand Down Expand Up @@ -229,17 +224,22 @@ export const MixSteps = {
call: () => {
cy.contains(MixContent.Delay).should('exist').should('be.visible')
cy.get(MixLocators.Checkbox)
.contains('Delay')
.should('exist')
.should('be.visible')
.eq(0)
.click()
cy.contains(MixContent.DelayDuration).should('exist').should('be.visible')
cy.get(MixLocators.DelaySecondsInput)
cy.get(MixLocators.Checkbox)
.find(
'[name="aspirate_delay_seconds"], [name="dispense_delay_seconds"]'
)
.should('exist')
.should('be.visible')
.should('have.prop', 'value')
cy.get(MixLocators.DelaySecondsInput)
.eq(1)
cy.get(MixLocators.Checkbox)
.find(
'[name="aspirate_delay_seconds"], [name="dispense_delay_seconds"]'
)
.type('{selectAll}{backspace}5')
},
}),
Expand Down Expand Up @@ -271,12 +271,14 @@ export const MixSteps = {
call: () => {
cy.contains(MixContent.Blowout).should('exist').should('be.visible')
cy.get(MixLocators.Checkbox)
.contains('Blowout')
.should('exist')
.should('be.visible')
.eq(0)
.click()
cy.contains(MixContent.ChooseOption).should('exist').should('be.visible')
cy.get(MixLocators.BlowoutLtnDropdown)
cy.contains(MixContent.ChooseOption)
.should('exist')
.should('be.visible')
.closest('div[tabindex="0"]')
.should('exist')
.should('be.visible')
.click()
Expand Down Expand Up @@ -324,9 +326,9 @@ export const MixSteps = {
TouchTip: (): StepThunk => ({
call: () => {
cy.get(MixLocators.Checkbox)
.contains('Touch tip')
.should('exist')
.should('be.visible')
.eq(0)
.click()
cy.get(MixLocators.PosFromTop)
.should('exist')
Expand Down Expand Up @@ -381,10 +383,12 @@ export const MixSteps = {
cy.get(MixLocators.RenameBtn).should('exist').should('be.visible').click()
cy.contains(MixContent.NameStep).should('exist').should('be.visible')
cy.contains(MixContent.StepName).should('exist').should('be.visible')
cy.get(MixLocators.StepNameInput).should('have.value', 'Mix')
cy.get(MixLocators.StepNameInput)
.find('[type="text"]')
.should('have.value', 'Mix')
cy.contains(MixContent.StepNotes).should('exist').should('be.visible')
cy.get(MixLocators.StepNameInput)
.first()
.find('[type="text"]')
.type('{selectAll}{backspace}Cypress Mix Test')
cy.get(MixLocators.StepNotesInput).type(
'This is testing cypress automation in PD'
Expand Down Expand Up @@ -497,7 +501,7 @@ export const MixVerifications = {
cy.get(MixLocators.ResetToDefault).click()
cy.contains(MixContent.TopToBottom).should('exist').should('be.visible')
cy.contains(MixContent.LeftToRight).should('exist').should('be.visible')
cy.get(MixLocators.CancelAspSettings).should('exist').should('be.visible')

cy.get(MixLocators.Save).should('exist').should('be.visible')
},
}),
Expand All @@ -524,7 +528,6 @@ export const MixVerifications = {
cy.get(MixLocators.ZpositionInput).should('exist').should('be.visible')
cy.get(MixLocators.ZpositionInput).should('have.prop', 'value')
cy.get(MixLocators.ResetToDefault).should('exist').should('be.visible')
cy.get(MixLocators.CancelAspSettings).should('exist').should('be.visible')
cy.get(MixLocators.Save)
.should('exist')
.should('be.visible')
Expand Down
21 changes: 11 additions & 10 deletions protocol-designer/cypress/support/SetupSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export enum SetupLocators {
LiquidNameInput = 'input[name="displayName"]',
ModalShellArea = 'div[aria-label="ModalShell_ModalArea"]',
SaveButton = 'button[type="submit"]',
LiquidsDropdown = 'div[tabindex="0"].sc-ksBlkl',
LiquidsDropdown = 'div[tabindex="0"].sc-ksBlkl', // NOTE: locator
Div = 'div',
Button = 'button',
TempdeckTempInput = 'input[name="targetTemperature"]',
Expand All @@ -86,8 +86,8 @@ export enum SetupLocators {
button = 'button',
svg = 'svg',
exist = 'exist',
StepOptionsTestIDThreeDots = 'button.Btn-sc-o3dtr1-0.OverflowBtn___StyledBtn-sc-1mslfxo-0',
AspirateCheckbox = 'div.Checkbox___StyledFlex3-sc-1mvp7vt-0.gZwGCw.btdgeU',
StepOptionsTestIDThreeDots = 'button.Btn-sc-o3dtr1-0.OverflowBtn___StyledBtn-sc-1mslfxo-0', // NOTE: locator
AspirateCheckbox = 'div.Checkbox___StyledFlex3-sc-1mvp7vt-0.gZwGCw.btdgeU', // NOTE: locator
}

export const RegexSetupContent = {
Expand Down Expand Up @@ -327,7 +327,7 @@ export const SetupSteps = {
}),

/**
* Choose deck slot A2.
* Choose deck slot A2. Please
*/
ChoseDeckSlotA2: (): StepThunk => ({
call: () => {
Expand All @@ -347,7 +347,7 @@ export const SetupSteps = {
ChoseDeckSlotC2Labware: (): StepThunk => ({
call: () => {
chooseDeckSlot('C2')
.find('.Box-sc-8ozbhb-0.kIDovv')
.find('.Box-sc-8ozbhb-0.kIDovv') // NOTE: ??
.find('a[role="button"]')
.contains(RegexSetupContent.slotText)
.click({ force: true })
Expand Down Expand Up @@ -411,7 +411,7 @@ export const SetupSteps = {
ChoseDeckSlotWithLabware: (deckslot: string): StepThunk => ({
call: () => {
chooseDeckSlot(deckslot)
.find('.Box-sc-8ozbhb-0.kIDovv')
.find('.Box-sc-8ozbhb-0.kIDovv') // NOTE: ??
.find('a[role="button"]')
.contains(RegexSetupContent.slotText)
.click({ force: true })
Expand Down Expand Up @@ -513,6 +513,7 @@ export const SetupSteps = {
cy.get(SetupLocators.LiquidsDropdown).should('be.visible').click()
},
}),
// cy.contains('p', 'Choose option').closest('div[tabindex="0"]').click()

/**
* Select "My liquid!" from the dropdown.
Expand Down Expand Up @@ -676,7 +677,7 @@ export const SetupSteps = {
PrewetAspirate: (): StepThunk => ({
call: () => {
cy.contains('Pre-wet tip')
.closest('div.Flex-sc-1qhp8l7-0.fJriNr')
.closest('div.Flex-sc-1qhp8l7-0.fJriNr') // NOTE: locator
.find(SetupLocators.AspirateCheckbox)
.click()
},
Expand Down Expand Up @@ -769,17 +770,17 @@ export const SetupSteps = {
BlowoutTransferDestination: (): StepThunk => ({
call: () => {
cy.contains('Blowout')
.closest('div.Flex-sc-1qhp8l7-0.ckuVEF')
.closest('div.Flex-sc-1qhp8l7-0.ckuVEF') // NOTE: ?
.find('button[type="button"]')
.click()
cy.contains('Choose option').click()
cy.contains('Destination Well').click()
},
}),

DeleteSteps: (): StepThunk => ({
DeleteSteps: (stepNumStepType: string): StepThunk => ({
call: () => {
cy.get(SetupLocators.StepOptionsTestIDThreeDots).click()
cy.contains(stepNumStepType).parent().next('button').click()
cy.contains('Delete step').click()
cy.contains('button', 'Delete step').click()
},
Expand Down
Loading