Why pyautogui click not actually clicking

拈花ヽ惹草 提交于 2021-02-18 08:43:19

问题


I try to use the click function of Pyautogui, but the actual click doesn't happen or at least there is no change at the page though it moves the mouse to the right place.

The window is in focus (I think) because the program works well with other pages.

I could only find one relevant question: having trouble clicking in program - pyautogui. However, there was no accepted answer for that and I tried the given answer in the link but didn't work (It was in python2 but I'm in python3).

I use Linux. I have no idea why the mouse moves to the right place but doesn't perform the click.

The code:

   from selenium import webdriver
   import pyautogui as py
   import time
   import pandas as pd
   browser=webdriver.Firefox()
   browser.maximize_window()
   browser.get("http://jao.eu/marketdata/dailyauctions")
   py.click(x=745,y=692, interval=1)

回答1:


Try editing as follows:

from selenium import webdriver
import pyautogui as py
import time
browser=webdriver.Chrome()
browser.maximize_window()
browser.get('http://jao.eu/marketdata/dailyauctions')
#Allows time for webpage to load
time.sleep(5)
#Set clicks parameter to 2
py.click(x=745,y=692, clicks=2, interval=1)

Setting the clicks parameter to 2 within the click() function will make the chrome browser just opened the active window and the second click will click the link at the coordinates entered in the click() function.



来源:https://stackoverflow.com/questions/52406707/why-pyautogui-click-not-actually-clicking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!