from selenium.webdriver import Remote
from threading import Thread
import time
def test(host,dc):
dr = Remote(command_executor=host,desired_capabilities=dc)
dr.get("https://www.baidu.com")
dr.maximize_window()
dr.find_element_by_id("kw").send_keys("selenium")
dr.find_element_by_id("su").click()
time.sleep(3)
dr.close()
lists = {
'http://localhost:4444/wd/hub':'chrome',
'http://192.168.201.8:7777/wd/hub':'chrome',
'http://192.168.201.1:6666/wd/hub':'chrome',
}
threads = []
for host,browser in lists.items():
print(host,browser)
t = Thread(target=test,args=(host,{"browserName":browser}))
threads.append(t)
print(threads)
for i in threads:
i.start()
for i in threads:
i.join()
python远程执行selenium代码demo
最新推荐文章于 2025-01-09 18:44:17 发布
882

被折叠的 条评论
为什么被折叠?



