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
最新推荐文章于 2023-02-07 18:31:27 发布