调用JavaScript.py

from selenium import webdriverfrom time import sleepdriver = webdriver.Firefox()driver.get("http://www.baidu.com")driver.set_window_size(600,600)driver.find_element_by_id("kw").send_keys("selenium")driver.find_element_by_id("su").click()sleep(2)#通过JavaScript设置浏览器窗口的滚动条位置左边距100、上边距450js = "window.scrollTo(100,450);"driver.execute_script(js)

相关推荐