如何使用python中使用硒的键盘输入来导航网页
我目前正在一个网络刮擦项目中间。为了微调内容,我必须与网页的不同元素进行交互,特别是拖放光标。我已经尝试了Selenium中的拖放方法,但是由于某种原因,无法选择该元素,无论是使用XPath还是ClassName。但是,我可以选择上方的元素。我想通过“按”选项卡3次导航到光标,然后通过5次左箭头将其向左带。我已经尝试使用以下代码行进行:
action = actionChinains(driver)
action.click(criteres).send_keys(keys.tab * 3).send_keys(keys.ARROW_LOW_LEFFT *) 5).perform()
,
但它似乎不起作用,我不知道为什么。
I'm currently in the middle of a web scraping project. In order to fine tune the content I have to interact with different elements of a web page, specifically a drag and drop cursor. I have tried the drag and drop method within selenium but for some reason the element cannot be selected, be it with xpath or classname. I can, however, select the element above it. I want to navigate to the cursor by "pressing" tab 3 times and then bring it to the left by "pressing" left arrow 5 times. I have tried doing so with the following lines of code:
actions = ActionChains(driver)
actions.click(criteres).send_keys(Keys.TAB * 3).send_keys(Keys.ARROW_LEFT * 5).perform()
But it doesn't seem to work and I can't figure out why.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用以下内容:
Use the following: