How to launch multiple browsers with multiple threads in python selenium webdriver
This article mainly explains "python selenium webdriver how to start multiple browsers with multiple threads". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to start multiple browsers with multi-thread in python selenium webdriver.
# introduce the necessary package from selenium import webdriverimport timeimport threading_author_=' Xiaoqiang test brand www.xqtesting.com'def test_search (browser, url): if browser = = "firefox": driver = webdriver.Firefox () elif browser = = "chrome": driver = webdriver.Chrome () # visit the official website of Test Group Diary And search for the keywords Xiaoqiang test brand driver.get (url) driver.find_element ('id', "words"). Send_keys (' Xiaoqiang test brand') driver.find_element ('class name',' btn-default'). Click () time.sleep (5) driver.quit () data = {"firefox": "http://www.xqtesting.com"," "chrome": "http://www.xqtesting.com/blog.html"}threads = [] for browser, url in data.items (): # Multithreading T1 = threading.Thread (target=test_search, args= (browser, url,)) threads.append (T1) # start for T2 in threads: t2.start () t2.join () # comment here will run at the same time. But there may be problems caused by occlusion when running at the same time. Thank you for your reading, the above is the content of "how to start multiple browsers with multiple threads in python selenium webdriver". After the study of this article, I believe you have a deeper understanding of how to start multiple browsers with multiple threads in python selenium webdriver, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!