问题
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