from time import sleep
import pyautogui
from selenium import webdriver
from selenium.webdriver import ActionChains
def test2():
driver = webdriver.Chrome(executable_path='E:\my_selenium_project\driver\chromedriver.exe')
driver.get('http://www.jpress.io/user/register')
driver.maximize_window()
ele = driver.find_element_by_id('agree')
ActionChains(driver).move_to_element(ele).click().perform()
sleep(30)
#老师的代码在自己机器上无法成功定位,改用ActionChains成功解决
# rect = ele.rect
# pyautogui.click(rect['x'] + 10, rect['y'] + 130)
# sleep(30)
if __name__ == '__main__':
test2()