import time
from webdriver_helper import webdriver, get_webdriver
from selenium.webdriver import chrome
from selenium.webdriver.common.by import By
driver = webdriver.Chrome() # 实例化 ,刚启动浏览器是空白页面
driver.maximize_window() # 窗口最大化
driver.get("http://118.24.147.95:8087/cookies/set/a/1") # 服务器会设置cookie
# driver.execute_script('alert(1)')#最简单JS代码
res=driver.execute_script("return 1+arguments[0];","1000")#js函数的参数和返回值
print(res)
input("按下回车.........")
driver.quit() # 退出浏览器 调用对象的方法
执行结果
11000
按下回车.........
Process finished with exit code 0
标签:webdriver,selenium,代码,driver,JS,.........,import
From: https://www.cnblogs.com/cy-xt/p/16852913.html