driver.js icon indicating copy to clipboard operation
driver.js copied to clipboard

Skip step for missing element

Open lonix1 opened this issue 1 year ago • 2 comments

(This is a question rather than bug report, as the repo doesn't have a "discussions" tab.)

New user here. I'm using the CDN script, on a server-rendered app.

Suppose my page does not contains some element. When that step is reached, a popup is shown in the middle of the screen, with the relevant text and buttons.

I'd like to skip that step.

I know of the "async actions" feature, but it doesn't apply here - I don't want to wait for that element to be created, rather, I want to skip that step.

Is that possible?

lonix1 avatar May 02 '24 03:05 lonix1

Just saw this in another issue (#484). Filter steps that have valid selectors. But this doesn't account for elements that get removed over time as this would be done on initialization of the tour...

const filteredSteps: any = steps.filter(step => {
  const element = document.querySelector(step.element)
  return !step.element || element !== null
})

You could probably also check the onNextClick()/... handlers to check if the next/... N steps are possible otherwise skip them.

Querela avatar Jun 07 '24 10:06 Querela

Those are good workarounds to avoid the problem.

The best solution though is to have a built-in mechanism for this... something like "if selector is invalid, skip step". And configurable by an option of course.

lonix1 avatar Jun 07 '24 11:06 lonix1