Double Click 在 Python 中不适用于 headless Selenium
Double Click does not work with headless Selenium in Python
我试图在无头模式下使用 selenium 双击网站上的选定元素,但是双击操作不起作用。我的 chrome 版本是 72。任何帮助将不胜感激。以下是我的代码的相关部分。
element = driver.find_element_by_id('player-forpost-html5').click()
time.sleep(5)
action = ActionChains(driver)
element_1 = driver.find_element_by_id('player-forpost-html5')
action.move_to_element(element_1)
action.double_click(element_1)
action.perform()
element_1.click()
对于无头 chrome 浏览器,您还需要在 chrome 选项中提供 window 大小。
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('window-size=1920x1480')
请尝试一下,如果可行请告诉我。
我试图在无头模式下使用 selenium 双击网站上的选定元素,但是双击操作不起作用。我的 chrome 版本是 72。任何帮助将不胜感激。以下是我的代码的相关部分。
element = driver.find_element_by_id('player-forpost-html5').click()
time.sleep(5)
action = ActionChains(driver)
element_1 = driver.find_element_by_id('player-forpost-html5')
action.move_to_element(element_1)
action.double_click(element_1)
action.perform()
element_1.click()
对于无头 chrome 浏览器,您还需要在 chrome 选项中提供 window 大小。
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('window-size=1920x1480')
请尝试一下,如果可行请告诉我。