Using RSelenium, I want to click the
enter image description here
button. this page has two views a desktop mode and a mobile mode,
I think the desktop view is hidden and does not allow you to click. enter image description here.
server <- phantomjs(port=5005L)
remDr <- remoteDriver(browserName = "phantomjs", port=5005L)
remDr$open()
remDr$navigate("https://catalogo.movistar.com.pe/samsung-galaxy-note-10-plus")
remDr$screenshot(display = TRUE)
element<- remDr$findElement(using = 'css selector', "body > div:nth-child(6) > div.container.detail-view > div.detail-main-head-container > div.detail-main-right > div.phone-details-specs > div.phone-specs > div.phone-specs-planes > div > div > div.owl-stage-outer > div > div:nth-child(4)")
element$clickElement()
remDr$screenshot(display = TRUE)
Apparently I must show the hidden view to be able to click because in mobile mode I do not get it.
Your help please. Aquí le tome una foto a mi pantalla con las salidas de la ejecución del código enter image description here
Related
I'm trying to get the main image on this website
The problem is that the main image is loaded via the HTML canvas tag. When I inspect the source code, the image is loaded in here, with no information on any file:
<canvas id="image1" class="mesImages ui-draggable" style="position: fixed; width: …ransform: rotate(0deg);" title="" tabindex="-1" width="359" height="542">
Is it possible to use RSelenium (and not Python) to get the image in .png or .jpg?
Gathering links with RSelenium
library(tidyverse)
library(RSelenium)
library(netstat)
rD <- rsDriver(browser = "firefox", port = free_port())
remDr <- rD[["client"]]
remDr$navigate("https://archives.landes.fr/arkotheque/visionneuse/visionneuse.php?arko=YTo3OntzOjQ6ImRhdGUiO3M6MTA6IjIwMjItMTAtMTgiO3M6MTA6InR5cGVfZm9uZHMiO3M6MTE6ImFya29fc2VyaWVsIjtzOjQ6InJlZjEiO3M6MToiNCI7czo0OiJyZWYyIjtzOjM6IjE3MyI7czoyMjoiZm9yY2VfbnVtX2ltYWdlX2RlcGFydCI7aTozNDA7czoxNjoidmlzaW9ubmV1c2VfaHRtbCI7YjoxO3M6MjE6InZpc2lvbm5ldXNlX2h0bWxfbW9kZSI7czo0OiJwcm9kIjt9")
accept <- remDr$findElement("xpath", '//*[#id="licence_clic_bouton_accepter"]')
accept$clickElement()
more <- remDr$findElement("css selector", "#arkoVision_barToggleButton_bottom")
more$clickElement()
content <- remDr$getPageSource()[[1]]
links <- content %>%
read_html() %>%
html_elements(".imgThumb_container") %>%
html_children() %>%
html_attr("rel") %>%
.[!is.na(.)]
> links %>% head()
[1] "https://archives.landes.fr/arkotheque/visionneuse/img_prot.php?i=13a087d1f5.jpg"
[2] "https://archives.landes.fr/arkotheque/visionneuse/img_prot.php?i=2159e78416.jpg"
[3] "https://archives.landes.fr/arkotheque/visionneuse/img_prot.php?i=65786a44b1.jpg"
[4] "https://archives.landes.fr/arkotheque/visionneuse/img_prot.php?i=702fbd57fa.jpg"
[5] "https://archives.landes.fr/arkotheque/visionneuse/img_prot.php?i=9c4421d51e.jpg"
[6] "https://archives.landes.fr/arkotheque/visionneuse/img_prot.php?i=a4b68fd913.jpg"
Typing <html> automatically creates </html> after your cursor in Brackets:
But when you press enter it just puts the closing tag on the next line:
To begin adding code I need to press (enter * 2), up arrow, tab (too many steps).
How can I do this automatically so that pressing enter results in:
Couldn't find an extension that does this.
This works natively in CSS, why not in HTML?
UPDATE: arsakasra's comment works really well!
Press enter followed by (CMD on Mac or CTRL on PC) + shift + enter
I've been playing around with the preferences and added the following to my brackets.json file (access in Menu Bar: Debug: "Open Preferences File").
"closeTags": {
"dontCloseTags": ["br", "hr", "img", "input", "link", "meta", "area", "base", "col", "command", "embed", "keygen", "param", "source", "track", "wbr"],
"indentTags": ["ul", "ol", "div", "section", "table", "tr"],
}
dontCloseTags are tags such as <br> which shouldn't be closed.
indentTags are tags that you want to automatically create a new
indented line - add more as needed!
(any tags that aren't in above arrays will self-close on the
same line)
https://github.com/shumpei/brackets-autoindent-extension
Here is a link for an extension on the Brackets that add the Auto-Indent feature.
I'm writing an automation script with RSelenium and I need it to open page http://bit. do and click on "Shorten" button. I tried to select element by css and xpath with selector gadget but the suggestions it gave to me weren't useful because with these attempts I got "element not visible"
#CSS SELECTOR ATTEMPT
shorten <- remDr$findElement('css selector', '.btn')
shorten$clickElement()
#XPATH ATTEMPT
shorten <- remDr$findElement('xpath', '//*[contains(concat( " ", #class, " " ), concat( " ", "btn", " " ))]')
shorten$clickElement()
Also I tried
shorten <- remDr$findElement(using ='value', value = 'Shorten')
shorten <- remDr$findElement('css selector', '.btn')
shorten <- remDr$findElement('css selector', 'input.btn')
shorten <- remDr$findElement('css selector', 'td>.btn')
shorten <- remDr$findElement('css selector', 'td. btn')
css:
input[value=Shorten]
input[onclick*=shorten]
xpath:
//input[#value='Shorten']
//input(contains(#onclick, 'shorten'))
How can I manually scroll to the bottom (or top) of a page with the RSelenium WebDriver? I have an element that only becomes available when it is visible on the page.
Assuming you got
library(RSelenium)
startServer()
remDr <- remoteDriver()
remDr$open()
remDr$setWindowSize(width = 800, height = 300)
remDr$navigate("https://www.r-project.org/about.html")
You could scroll to the buttom like this:
webElem <- remDr$findElement("css", "body")
webElem$sendKeysToElement(list(key = "end"))
And you could scroll to the top like this:
webElem$sendKeysToElement(list(key = "home"))
And in case you want to scroll down just a bit, use
webElem$sendKeysToElement(list(key = "down_arrow"))
The names of the keys are in selKeys.
I use the library (tcltk) in R to make the GUI. Code to create a button is :
tt <- tktoplevel()
button.widget <- tkbutton(tt, text = "", command = function())
I want the existing button on the GUI has an icon. How is the code to add the icon in the button using the library (tcltk) in R?
Use the tkimage.create function to create a Tcl-level representation of an image file. Note that there are some limitations on image formats and I believe GIF is the easiest to work with. Then, you specify the image as the image argument to tkbutton. Here's an example using, an Example.gif from Wikipedia:
library("tcltk")
img <- tclVar()
tclimg <- tkimage.create("photo", img, file = "Example.gif")
tt <- tktoplevel()
button.widget <- tkbutton(tt, text = "Click me!", image = tclimg, compound = "top",
command = function() tkmessageBox(message = "Hello!"))
tkgrid(button.widget)
You can control the relative placement of the image and text on the button using the compound argument:
"none" (display only the image if present, otherwise the text; the default)
"text" (text only)
"image" (image only)
"center" (text in center of image)
"top" (image above text)
"left" (image left of text)
"bottom" (image below text)
"right" (image right of text)