sendkeystoelement执行,但在硒中未通过键
我很难更改
2021/m-itf-tun-52a-2021/draws-and-results/“ rel =“ nofollow noreferrer”>此页面与R中的 不是两个选项的单独XPath(“单打”和“双打”)。在选项之间切换时,我可以看到唯一不同的是最终节点的内容。
因此,我尝试了另一种方法来(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
我在这里做错了什么?我注意到,有些元素旁边有“ flex” - 这可能与它有关吗?
I am having difficulty changing the value of what appears to be a dropdown box (but I don't think is) on this page when interacting it with Selenium in R.
I don't think it's a dropdown because there are not separate xpaths for the 2 options ("Singles" and "Doubles"). When toggling between the options I can see that the only thing that differs is the content for the final node.
I have therefore tried a different method to (1) select the "dropdown", (2) type the option I want and then (3) click enter. However, this is not working because neither text nor keystrokes are being passed to the webpage.
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
What am I doing wrong here? I note that some elements have "flex" next to them - could this have anything to do with it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保在屏幕上可见下拉按钮,这应该像我一样工作:
Make sure the drop down button is visible on the screen and this should work as it did for me: