【问题标题】:Press Ctrl+Shift+c using Selenium webdriver is not working使用 Selenium webdriver 按 Ctrl+Shift+c 不起作用
【发布时间】:2020-07-02 13:07:14
【问题描述】:
driver.get("https://www.google.com) 

我想模拟用selenium按下Ctrl+Shift+c的过程

我试过了:

  1.    actions
            .keyDown(Keys.CONTROL)
            .keyDown(Keys.SHIFT)
            .sendKeys("c")
            .build()
            .perform();

  2.    action.sendKeys(Keys.chord(Keys.SHIFT + Keys.CONTROL + "c")).perform();

StackOverflow 里有很多答案,但没有任何作用

【问题讨论】:

  • 仅导航到页面后您希望复制什么?
  • 它应该打开 devTools,但不建议使用 chromeOptions 的方式
  • 为什么要模拟Ctrl+Shift+c而忽略ChromeOptions?你的具体用例是什么?
  • 问题不仅在于Ctrl+Shift+c的使用,其他操作(Ctrl+t、Ctrl+Shift+o等)也不起作用
  • @NorayrSargsyan 你的用例是什么?你想通过Ctrl+Shift+cCtrl+Shift+o 做什么?

标签: java selenium action


【解决方案1】:

您正在寻找类似pyautogui selenium 操作的行为不符合您的预期。

from selenium import webdriver
import pyautogui

driver = webdriver.Chrome(executable_path=r'C:\\Path\\To\\Your\\chromedriver.exe')
driver.get("https://www.google.com")

pyautogui.hotkey('ctrl','shift', 'c')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-03
    • 2011-08-09
    • 1970-01-01
    相关资源
    最近更新 更多