From dee3db4eaa7317b936600a7fae75cfbca45a069f Mon Sep 17 00:00:00 2001 From: eliastor Date: Tue, 22 Aug 2023 22:43:57 +0300 Subject: [PATCH] adding small instruction on how to get the selectors --- docs/data-sources/recipe.md | 23 +++++++++++++++++------ docs/index.md | 6 ++++++ internal/provider/data_recipe.go | 16 ++++++++++++---- templates/index.md.tmpl | 6 ++++++ 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/docs/data-sources/recipe.md b/docs/data-sources/recipe.md index 5229848..86fec90 100644 --- a/docs/data-sources/recipe.md +++ b/docs/data-sources/recipe.md @@ -4,17 +4,28 @@ page_title: "chromedp_recipe Data Source - terraform-provider-chromedp" subcategory: "" description: |- Recipe runs list of action sequentially. - If "screenshot_filename" is set it makes the screenshot after all actions executed. - All the actions are list of string where the first string is action name. - In most cases the second string is selector for the action. + If "screenshot_filename" is set it makes the screenshot after all actions executed. + All actions are list of string where the first string is action name. + In most cases the second string is selector for the action. + The easiest way to get the selector for the element: + Open Devtools -> select element in DOM (or right click on the element at page and click "inspect element) -> right click on the element in dev tools: copy -> copy selector. + For more information about selectors https://en.wikipedia.org/wiki/CSS#Selector --- # chromedp_recipe (Data Source) Recipe runs list of action sequentially. - If "screenshot_filename" is set it makes the screenshot after all actions executed. - All the actions are list of string where the first string is action name. - In most cases the second string is selector for the action. +If "screenshot_filename" is set it makes the screenshot after all actions executed. + +All actions are list of string where the first string is action name. + +In most cases the second string is selector for the action. + +The easiest way to get the selector for the element: + +Open Devtools -> select element in DOM (or right click on the element at page and click "inspect element) -> right click on the element in dev tools: copy -> copy selector. + +For more information about selectors https://en.wikipedia.org/wiki/CSS#Selector ## Example Usage diff --git a/docs/index.md b/docs/index.md index 73898d4..7bb9354 100644 --- a/docs/index.md +++ b/docs/index.md @@ -12,6 +12,12 @@ This providers allows you to use [chromedp](https://github.com/chromedp/chromedp The easiest way to start using it is to install local Chrome or to create container with headless chrome, for an instance: `podman run --rm -d -p 3000:3000 docker.io/browserless/chrome:latest` +The easiest way to get the selector for the element: + +Open Devtools -> select element in DOM (or right click on the element at page and click "inspect element) -> right click on the element in dev tools: copy -> copy selector. + +For more information about selectors https://en.wikipedia.org/wiki/CSS#Selector + ## Example Usage ```terraform diff --git a/internal/provider/data_recipe.go b/internal/provider/data_recipe.go index fbfa485..160d1d0 100644 --- a/internal/provider/data_recipe.go +++ b/internal/provider/data_recipe.go @@ -43,10 +43,18 @@ func (d *RecipeDataSource) Metadata(ctx context.Context, req datasource.Metadata func (d *RecipeDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - Description: `Recipe runs list of action sequentially. - If "screenshot_filename" is set it makes the screenshot after all actions executed. - All the actions are list of string where the first string is action name. - In most cases the second string is selector for the action.`, + MarkdownDescription: `Recipe runs list of action sequentially. +If "screenshot_filename" is set it makes the screenshot after all actions executed. + +All actions are list of string where the first string is action name. + +In most cases the second string is selector for the action. + +The easiest way to get the selector for the element: + +Open Devtools -> select element in DOM (or right click on the element at page and click "inspect element) -> right click on the element in dev tools: copy -> copy selector. + +For more information about selectors https://en.wikipedia.org/wiki/CSS#Selector`, Attributes: map[string]schema.Attribute{ "actions": schema.ListAttribute{ ElementType: types.ListType{ diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl index b45f98a..71db9ef 100644 --- a/templates/index.md.tmpl +++ b/templates/index.md.tmpl @@ -12,6 +12,12 @@ This providers allows you to use [chromedp](https://github.com/chromedp/chromedp The easiest way to start using it is to install local Chrome or to create container with headless chrome, for an instance: `podman run --rm -d -p 3000:3000 docker.io/browserless/chrome:latest` +The easiest way to get the selector for the element: + +Open Devtools -> select element in DOM (or right click on the element at page and click "inspect element) -> right click on the element in dev tools: copy -> copy selector. + +For more information about selectors https://en.wikipedia.org/wiki/CSS#Selector + ## Example Usage {{ tffile "examples/provider/provider.tf" }}