How to zoom out page using RSelenium library in R?

痴心易碎 提交于 2021-02-08 20:38:29

问题


I am trying to write a web-scraper using RSelenium Library in R. The last step of my work includes taking screenshot of a table on web page. To fit the whole table into the window I should zoom out the web browser (in that case it's firefox). I tried to use:

webElem <- remDR$findElement("css", "body")
webElem$clickElement()
webElem$sendKeysToElement(list(key = "control", "-"))

however it doesn't work. I saw also this thread: Zoom out shiny app at default in browser and found there promising fragment of code: library(shiny)

# Define UI for application that draws a histogram
ui <- shinyUI(fluidPage(
   tags$style("
          body {
    -moz-transform: scale(0.8, 0.8); /* Moz-browsers */
    zoom: 0.8; /* Other non-webkit browsers */
    zoom: 80%; /* Webkit browsers */
}
              "),

I have no idea if it's possible to do something similiar in R Selenium and how to implement css scale modification in RSelenium. Iwould appreciate hints from someone more experienced with R.


回答1:


It turned out, that good solution to my problem was simple change of resolution in RSelenium:

remDR$setWindowSize(2496, 1404)

It works fine for my current purpose.



来源:https://stackoverflow.com/questions/46266019/how-to-zoom-out-page-using-rselenium-library-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!