我有困难改变什么似乎是一个下拉框的值(但我不认为是)在这个页面上与硒交互时,它在r
我不认为这是一个下拉菜单,因为这两个选项没有单独的路径("Singles")和"Doubles"。当在选项之间切换时,我可以看到唯一不同的是最终节点的内容。
因此,我尝试了一种不同的方法:(1)选择"下拉",(2)键入我想要的选项,然后(3)单击enter。但是,这不能工作,因为文本和按键都没有传递到网页。library('RSelenium')
library('rvest')
library('tidyverse')
library('seleniumPipes')
single.double.elem <- remDr$findElement(using = 'xpath', "//*[@class=' css-1hwfws3']") #find element
single.double.elem$clickElement() #click it
single.double.elem$sendKeysToElement(list("Doubles")) #attempt to type into box. This executes but the text is not passed to the box
single.double.elem$sendKeysToElement(list(key = "down_arrow")) #alternatively, attempt to go down to select Doubles option. This executes but nothing happens
我在这里做错了什么?我注意到有些元素具有"弹性"。在他们旁边,这和它有关系吗?
确保下拉按钮在屏幕上可见,这应该像它为我做的那样工作:
# to click on Doubles dropdown
dropdownButton <- remdr$findElement(using = 'xpath', value = "//span[@class='icon']")$clickElement()
selectButton <- remdr$findElement(using = 'xpath', value = "//div[text()='Doubles']")$clickElement()
# to click on Singles dropdown
dropdownButton <- remdr$findElement(using = 'xpath', value = "//span[@class='icon']")$clickElement()
selectButton <- remdr$findElement(using = 'xpath', value = "//div[text()='Singles']")$clickElement()