Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
257 views
in Technique[技术] by (71.8m points)

Python selenium库 对象怎么指向当前的webdriver对象呢?

wd = webdriver.Chrome('D:Program FilesPythonPython38chromedriver.exe')
wd.implicitly_wait(10)
wd.get('http...........................')


def run_js(js_path):#运行js文件,注意webdriver对象必须名叫wb
    f = open(file = js_path , encoding ='utf-8')
    js = f.read()
    wd.execute_script(js)
    f.close()

我写了个def,就是运行js 脚本的,里面这个webdriver对象叫 wb,
我想把这个 wd 改成当前 webdriver 对象,请问该怎么写呢?

因为有时候他不叫wb……


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

将wb作为参数传到run_js里


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...