knitr::opts_chunk$set( collapse = TRUE, eval = F, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
{playwrightr} provides access the python library playwright
Playwright emulates web browsers and enables reliable end-to-end testing for modern web apps.
```{bash, eval = F} conda create -n pw python=3.7 conda activate pw conda config --add channels conda-forge conda config --add channels microsoft conda install playwright playwright install
2. Install playwrightr from GitHub ``` r # install.packages("devtools") devtools::install_github("benjaminguinaudeau/playwrightr")
This is a basic example which shows you how to solve a common problem:
reticulate::use_python("/home/ben/anac/bin/python", required = TRUE) options(python_init = TRUE) library(reticulate) library(playwrightr) library(dplyr) pw_init(use_xvfb = F) # Launch the browser browser_df <- browser_launch(browser = "firefox", user_data_dir = tempdir(), headless = T) # Create a new page page_df <- new_page(browser_df)
page_df %>% goto("https://google.com") page_df %>% get_by_selector("input") %>% split(1:nrow(.)) %>% purrr::map_dfr(~{ attrs <- get_all_attributes(.x) attrs }) %>% glimpse
chrome <- new_browser("chrome", headless = F) page <- chrome$pages[[1]] page$goto("https://google.com")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.