grafana / plugin-tools

Create Grafana plugins with ease.
https://grafana.com/developers/plugin-tools/
Apache License 2.0
58 stars 32 forks source link

Question: get "switch" element in E2E test #1251

Closed vitPinchuk closed 1 month ago

vitPinchuk commented 1 month ago

How to correctly get the switch element in the main version so that the approach works for older versions as well ? The Switch element is located in the panel options on the edit page. Image

Current implementation (works on version 11.3.0 and lower). Find switch and toggle it

.editPage
      .getByGrafanaSelector(
        this.editPage.ctx.selectors.components.PanelEditor.OptionsPane.fieldLabel('Business Table Exportable')
      )
      .getByLabel('Toggle switch')
      .click();

This does not work in the main version ("version": "11.4.0-204366")

Can`t get the element (element(s) not found)

      .getByGrafanaSelector(
        this.editPage.ctx.selectors.components.PanelEditor.OptionsPane.fieldLabel('Business Table Exportable')
      )
      .getByLabel('Toggle switch')

Thanks

tolzhabayev commented 1 month ago

@sunker ptal

sunker commented 1 month ago

Thanks for raising this issue @vitPinchuk!

I just raised this PR that introduces a selector that works across multiple versions of Grafana.

This makes me think plugin-e2e may need to have some kind of abstraction that bridges the gap between different versions of Grafana. I'll try to come up with a solution for this, but in the meantime you can copy the snippet from my PR above and it should work.

grafana-plugins-platform-bot[bot] commented 1 month ago

:rocket: Issue was released in @grafana/create-plugin@5.7.1 :rocket: